Merge branch 'mesabetter'
This commit is contained in:
commit
683e7cc845
|
@ -170,6 +170,51 @@ if $(HAIKU_BUILD_FEATURE_CLUCENE) {
|
|||
}
|
||||
|
||||
|
||||
# Mesa
|
||||
local mesaBaseURL = http://pub.haikufire.com/mesa ;
|
||||
if $(TARGET_ARCH) = x86 {
|
||||
local zipFile ;
|
||||
if $(HAIKU_GCC_VERSION[1]) >= 4 {
|
||||
HAIKU_MESA_FILE = mesa-71cc639-gcc4-x86.zip ;
|
||||
} else {
|
||||
HAIKU_MESA_FILE = mesa-7.8.2-gcc2-x86.zip ;
|
||||
}
|
||||
|
||||
zipFile = [ DownloadFile $(HAIKU_MESA_FILE)
|
||||
: $(mesaBaseURL)/$(HAIKU_MESA_FILE) ] ;
|
||||
|
||||
HAIKU_MESA_DIR = [ FDirName $(HAIKU_OPTIONAL_BUILD_PACKAGES_DIR)
|
||||
$(HAIKU_MESA_FILE:B) ] ;
|
||||
|
||||
HAIKU_MESA_HEADERS_DEPENDENCY = [ ExtractArchive $(HAIKU_MESA_DIR)
|
||||
: include/ : $(zipFile) : extracted-mesa ] ;
|
||||
|
||||
if $(HAIKU_GCC_VERSION[1]) >= 4 {
|
||||
HAIKU_MESA_LIBS = [ ExtractArchive $(HAIKU_MESA_DIR)
|
||||
:
|
||||
src/mesa/libmesa.a
|
||||
src/mapi/glapi/libglapi.a
|
||||
lib/libGLU.a
|
||||
: $(zipFile)
|
||||
: extracted-mesa ] ;
|
||||
} else {
|
||||
# Older Mesa 7.8
|
||||
HAIKU_MESA_LIBS = [ ExtractArchive $(HAIKU_MESA_DIR)
|
||||
:
|
||||
src/mesa/libmesa.a
|
||||
src/mesa/libglapi.a
|
||||
lib/libGLU.a
|
||||
: $(zipFile)
|
||||
: extracted-mesa ] ;
|
||||
}
|
||||
|
||||
HAIKU_MESA_HEADERS = [ FDirName $(HAIKU_MESA_DIR) include ] ;
|
||||
|
||||
} else {
|
||||
Echo "Mesa 3D rendering support not available on $(TARGET_ARCH)" ;
|
||||
}
|
||||
|
||||
|
||||
# TagLib
|
||||
|
||||
# Automatically install the TagLib feature, when the optional TagLib optional
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,353 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __glu_h__
|
||||
#define __glu_h__
|
||||
|
||||
#if defined(USE_MGL_NAMESPACE)
|
||||
#include "glu_mangle.h"
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define GLAPIENTRY __stdcall
|
||||
#else
|
||||
#define GLAPIENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAPIENTRYP
|
||||
#define GLAPIENTRYP GLAPIENTRY *
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
|
||||
# undef GLAPI
|
||||
# define GLAPI __declspec(dllexport)
|
||||
#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL)
|
||||
/* tag specifying we're building for DLL runtime support */
|
||||
# undef GLAPI
|
||||
# define GLAPI __declspec(dllimport)
|
||||
#elif !defined(GLAPI)
|
||||
/* for use with static link lib build of Win32 edition only */
|
||||
# define GLAPI extern
|
||||
#endif /* _STATIC_MESA support */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
/* Extensions */
|
||||
#define GLU_EXT_object_space_tess 1
|
||||
#define GLU_EXT_nurbs_tessellator 1
|
||||
|
||||
/* Boolean */
|
||||
#define GLU_FALSE 0
|
||||
#define GLU_TRUE 1
|
||||
|
||||
/* Version */
|
||||
#define GLU_VERSION_1_1 1
|
||||
#define GLU_VERSION_1_2 1
|
||||
#define GLU_VERSION_1_3 1
|
||||
|
||||
/* StringName */
|
||||
#define GLU_VERSION 100800
|
||||
#define GLU_EXTENSIONS 100801
|
||||
|
||||
/* ErrorCode */
|
||||
#define GLU_INVALID_ENUM 100900
|
||||
#define GLU_INVALID_VALUE 100901
|
||||
#define GLU_OUT_OF_MEMORY 100902
|
||||
#define GLU_INCOMPATIBLE_GL_VERSION 100903
|
||||
#define GLU_INVALID_OPERATION 100904
|
||||
|
||||
/* NurbsDisplay */
|
||||
/* GLU_FILL */
|
||||
#define GLU_OUTLINE_POLYGON 100240
|
||||
#define GLU_OUTLINE_PATCH 100241
|
||||
|
||||
/* NurbsCallback */
|
||||
#define GLU_NURBS_ERROR 100103
|
||||
#define GLU_ERROR 100103
|
||||
#define GLU_NURBS_BEGIN 100164
|
||||
#define GLU_NURBS_BEGIN_EXT 100164
|
||||
#define GLU_NURBS_VERTEX 100165
|
||||
#define GLU_NURBS_VERTEX_EXT 100165
|
||||
#define GLU_NURBS_NORMAL 100166
|
||||
#define GLU_NURBS_NORMAL_EXT 100166
|
||||
#define GLU_NURBS_COLOR 100167
|
||||
#define GLU_NURBS_COLOR_EXT 100167
|
||||
#define GLU_NURBS_TEXTURE_COORD 100168
|
||||
#define GLU_NURBS_TEX_COORD_EXT 100168
|
||||
#define GLU_NURBS_END 100169
|
||||
#define GLU_NURBS_END_EXT 100169
|
||||
#define GLU_NURBS_BEGIN_DATA 100170
|
||||
#define GLU_NURBS_BEGIN_DATA_EXT 100170
|
||||
#define GLU_NURBS_VERTEX_DATA 100171
|
||||
#define GLU_NURBS_VERTEX_DATA_EXT 100171
|
||||
#define GLU_NURBS_NORMAL_DATA 100172
|
||||
#define GLU_NURBS_NORMAL_DATA_EXT 100172
|
||||
#define GLU_NURBS_COLOR_DATA 100173
|
||||
#define GLU_NURBS_COLOR_DATA_EXT 100173
|
||||
#define GLU_NURBS_TEXTURE_COORD_DATA 100174
|
||||
#define GLU_NURBS_TEX_COORD_DATA_EXT 100174
|
||||
#define GLU_NURBS_END_DATA 100175
|
||||
#define GLU_NURBS_END_DATA_EXT 100175
|
||||
|
||||
/* NurbsError */
|
||||
#define GLU_NURBS_ERROR1 100251
|
||||
#define GLU_NURBS_ERROR2 100252
|
||||
#define GLU_NURBS_ERROR3 100253
|
||||
#define GLU_NURBS_ERROR4 100254
|
||||
#define GLU_NURBS_ERROR5 100255
|
||||
#define GLU_NURBS_ERROR6 100256
|
||||
#define GLU_NURBS_ERROR7 100257
|
||||
#define GLU_NURBS_ERROR8 100258
|
||||
#define GLU_NURBS_ERROR9 100259
|
||||
#define GLU_NURBS_ERROR10 100260
|
||||
#define GLU_NURBS_ERROR11 100261
|
||||
#define GLU_NURBS_ERROR12 100262
|
||||
#define GLU_NURBS_ERROR13 100263
|
||||
#define GLU_NURBS_ERROR14 100264
|
||||
#define GLU_NURBS_ERROR15 100265
|
||||
#define GLU_NURBS_ERROR16 100266
|
||||
#define GLU_NURBS_ERROR17 100267
|
||||
#define GLU_NURBS_ERROR18 100268
|
||||
#define GLU_NURBS_ERROR19 100269
|
||||
#define GLU_NURBS_ERROR20 100270
|
||||
#define GLU_NURBS_ERROR21 100271
|
||||
#define GLU_NURBS_ERROR22 100272
|
||||
#define GLU_NURBS_ERROR23 100273
|
||||
#define GLU_NURBS_ERROR24 100274
|
||||
#define GLU_NURBS_ERROR25 100275
|
||||
#define GLU_NURBS_ERROR26 100276
|
||||
#define GLU_NURBS_ERROR27 100277
|
||||
#define GLU_NURBS_ERROR28 100278
|
||||
#define GLU_NURBS_ERROR29 100279
|
||||
#define GLU_NURBS_ERROR30 100280
|
||||
#define GLU_NURBS_ERROR31 100281
|
||||
#define GLU_NURBS_ERROR32 100282
|
||||
#define GLU_NURBS_ERROR33 100283
|
||||
#define GLU_NURBS_ERROR34 100284
|
||||
#define GLU_NURBS_ERROR35 100285
|
||||
#define GLU_NURBS_ERROR36 100286
|
||||
#define GLU_NURBS_ERROR37 100287
|
||||
|
||||
/* NurbsProperty */
|
||||
#define GLU_AUTO_LOAD_MATRIX 100200
|
||||
#define GLU_CULLING 100201
|
||||
#define GLU_SAMPLING_TOLERANCE 100203
|
||||
#define GLU_DISPLAY_MODE 100204
|
||||
#define GLU_PARAMETRIC_TOLERANCE 100202
|
||||
#define GLU_SAMPLING_METHOD 100205
|
||||
#define GLU_U_STEP 100206
|
||||
#define GLU_V_STEP 100207
|
||||
#define GLU_NURBS_MODE 100160
|
||||
#define GLU_NURBS_MODE_EXT 100160
|
||||
#define GLU_NURBS_TESSELLATOR 100161
|
||||
#define GLU_NURBS_TESSELLATOR_EXT 100161
|
||||
#define GLU_NURBS_RENDERER 100162
|
||||
#define GLU_NURBS_RENDERER_EXT 100162
|
||||
|
||||
/* NurbsSampling */
|
||||
#define GLU_OBJECT_PARAMETRIC_ERROR 100208
|
||||
#define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208
|
||||
#define GLU_OBJECT_PATH_LENGTH 100209
|
||||
#define GLU_OBJECT_PATH_LENGTH_EXT 100209
|
||||
#define GLU_PATH_LENGTH 100215
|
||||
#define GLU_PARAMETRIC_ERROR 100216
|
||||
#define GLU_DOMAIN_DISTANCE 100217
|
||||
|
||||
/* NurbsTrim */
|
||||
#define GLU_MAP1_TRIM_2 100210
|
||||
#define GLU_MAP1_TRIM_3 100211
|
||||
|
||||
/* QuadricDrawStyle */
|
||||
#define GLU_POINT 100010
|
||||
#define GLU_LINE 100011
|
||||
#define GLU_FILL 100012
|
||||
#define GLU_SILHOUETTE 100013
|
||||
|
||||
/* QuadricCallback */
|
||||
/* GLU_ERROR */
|
||||
|
||||
/* QuadricNormal */
|
||||
#define GLU_SMOOTH 100000
|
||||
#define GLU_FLAT 100001
|
||||
#define GLU_NONE 100002
|
||||
|
||||
/* QuadricOrientation */
|
||||
#define GLU_OUTSIDE 100020
|
||||
#define GLU_INSIDE 100021
|
||||
|
||||
/* TessCallback */
|
||||
#define GLU_TESS_BEGIN 100100
|
||||
#define GLU_BEGIN 100100
|
||||
#define GLU_TESS_VERTEX 100101
|
||||
#define GLU_VERTEX 100101
|
||||
#define GLU_TESS_END 100102
|
||||
#define GLU_END 100102
|
||||
#define GLU_TESS_ERROR 100103
|
||||
#define GLU_TESS_EDGE_FLAG 100104
|
||||
#define GLU_EDGE_FLAG 100104
|
||||
#define GLU_TESS_COMBINE 100105
|
||||
#define GLU_TESS_BEGIN_DATA 100106
|
||||
#define GLU_TESS_VERTEX_DATA 100107
|
||||
#define GLU_TESS_END_DATA 100108
|
||||
#define GLU_TESS_ERROR_DATA 100109
|
||||
#define GLU_TESS_EDGE_FLAG_DATA 100110
|
||||
#define GLU_TESS_COMBINE_DATA 100111
|
||||
|
||||
/* TessContour */
|
||||
#define GLU_CW 100120
|
||||
#define GLU_CCW 100121
|
||||
#define GLU_INTERIOR 100122
|
||||
#define GLU_EXTERIOR 100123
|
||||
#define GLU_UNKNOWN 100124
|
||||
|
||||
/* TessProperty */
|
||||
#define GLU_TESS_WINDING_RULE 100140
|
||||
#define GLU_TESS_BOUNDARY_ONLY 100141
|
||||
#define GLU_TESS_TOLERANCE 100142
|
||||
|
||||
/* TessError */
|
||||
#define GLU_TESS_ERROR1 100151
|
||||
#define GLU_TESS_ERROR2 100152
|
||||
#define GLU_TESS_ERROR3 100153
|
||||
#define GLU_TESS_ERROR4 100154
|
||||
#define GLU_TESS_ERROR5 100155
|
||||
#define GLU_TESS_ERROR6 100156
|
||||
#define GLU_TESS_ERROR7 100157
|
||||
#define GLU_TESS_ERROR8 100158
|
||||
#define GLU_TESS_MISSING_BEGIN_POLYGON 100151
|
||||
#define GLU_TESS_MISSING_BEGIN_CONTOUR 100152
|
||||
#define GLU_TESS_MISSING_END_POLYGON 100153
|
||||
#define GLU_TESS_MISSING_END_CONTOUR 100154
|
||||
#define GLU_TESS_COORD_TOO_LARGE 100155
|
||||
#define GLU_TESS_NEED_COMBINE_CALLBACK 100156
|
||||
|
||||
/* TessWinding */
|
||||
#define GLU_TESS_WINDING_ODD 100130
|
||||
#define GLU_TESS_WINDING_NONZERO 100131
|
||||
#define GLU_TESS_WINDING_POSITIVE 100132
|
||||
#define GLU_TESS_WINDING_NEGATIVE 100133
|
||||
#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
class GLUnurbs;
|
||||
class GLUquadric;
|
||||
class GLUtesselator;
|
||||
#else
|
||||
typedef struct GLUnurbs GLUnurbs;
|
||||
typedef struct GLUquadric GLUquadric;
|
||||
typedef struct GLUtesselator GLUtesselator;
|
||||
#endif
|
||||
|
||||
typedef GLUnurbs GLUnurbsObj;
|
||||
typedef GLUquadric GLUquadricObj;
|
||||
typedef GLUtesselator GLUtesselatorObj;
|
||||
typedef GLUtesselator GLUtriangulatorObj;
|
||||
|
||||
#define GLU_TESS_MAX_COORD 1.0e150
|
||||
|
||||
/* Internal convenience typedefs */
|
||||
typedef void (GLAPIENTRYP _GLUfuncptr)();
|
||||
|
||||
GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb);
|
||||
GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
|
||||
GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString);
|
||||
GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
|
||||
GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad);
|
||||
GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
|
||||
GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb);
|
||||
GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error);
|
||||
GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
|
||||
GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name);
|
||||
GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
|
||||
GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view);
|
||||
GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);
|
||||
GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void);
|
||||
GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void);
|
||||
GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void);
|
||||
GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData);
|
||||
GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData);
|
||||
GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
|
||||
GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
|
||||
GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep);
|
||||
GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
|
||||
GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
|
||||
GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
|
||||
GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
|
||||
GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal);
|
||||
GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
|
||||
GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture);
|
||||
GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut);
|
||||
GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
|
||||
GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
|
||||
GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
|
||||
GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
|
||||
GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
|
||||
GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
|
||||
GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __glu_h__ */
|
|
@ -7,12 +7,13 @@ if $(TARGET_PLATFORM) != haiku {
|
|||
# We need our public GL headers also when not compiling for Haiku.
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
local defines ;
|
||||
defines = BEOS_THREADS GNU_ASSEMBLER ;
|
||||
|
||||
if $(TARGET_ARCH) = x86 {
|
||||
defines += USE_X86_ASM USE_MMX_ASM USE_3DNOW_ASM USE_SSE_ASM ;
|
||||
defines += USE_X86_ASM USE_MMX_ASM USE_3DNOW_ASM USE_SSE_ASM ;
|
||||
} else if $(TARGET_ARCH) = ppc {
|
||||
# Not yet supported, as current Mesa3D PPC assembly is Linux-dependent!
|
||||
# defines += USE_PPC_ASM ;
|
||||
|
@ -20,23 +21,34 @@ if $(TARGET_PLATFORM) != haiku {
|
|||
defines += USE_SPARC_ASM ;
|
||||
}
|
||||
|
||||
SubDirC++Flags [ FDefines $(defines) ] ;
|
||||
# For GCC2
|
||||
local flags ;
|
||||
if $(HAIKU_GCC_VERSION[1]) < 3 {
|
||||
flags = --no-warnings ;
|
||||
}
|
||||
|
||||
SubDirC++Flags [ FDefines $(defines) ] $(flags) ;
|
||||
}
|
||||
|
||||
|
||||
UsePrivateHeaders interface ;
|
||||
UseLibraryHeaders mesa ;
|
||||
local sources = MesaSoftwareRenderer.cpp ;
|
||||
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa main ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa glapi ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa tnl ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa x86 ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ppc ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa sparc ] ;
|
||||
UsePrivateHeaders interface ;
|
||||
SubDirSysHdrs $(HAIKU_MESA_HEADERS) ;
|
||||
Includes [ FGristFiles $(sources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ;
|
||||
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) include ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa main ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mapi ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mapi glapi ] ;
|
||||
|
||||
# For older versions of Mesa
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa glapi ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa tnl ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa x86 ] ;
|
||||
|
||||
Addon Mesa\ Software\ Renderer :
|
||||
MesaSoftwareRenderer.cpp
|
||||
: libGL.so libmesa.a be $(TARGET_LIBSUPC++)
|
||||
: libGL.so be $(TARGET_LIBSUPC++)
|
||||
;
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/*
|
||||
* Copyright 2006-2008, Haiku. All rights reserved.
|
||||
* Copyright 2006-2011, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval, korli@users.berlios.de
|
||||
* Philippe Houdoin, philippe.houdoin@free.fr
|
||||
* Artur Wyszynski, harakash@gmail.com
|
||||
* Alexander von Gluck, kallisti5@unixzen.com
|
||||
*/
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
|
@ -23,17 +24,20 @@
|
|||
#include <GraphicsDefs.h>
|
||||
#include <Screen.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
#include "extensions.h"
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
#include "drivers/common/meta.h"
|
||||
#include "main/colormac.h"
|
||||
#include "main/buffers.h"
|
||||
#include "main/formats.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/renderbuffer.h"
|
||||
#include "main/state.h"
|
||||
#include "main/version.h"
|
||||
#include "swrast/swrast.h"
|
||||
#if __GNUC__ > 2
|
||||
#include "swrast/s_renderbuffer.h"
|
||||
#endif
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
|
@ -199,6 +203,7 @@ extern "C" {
|
|||
|
||||
}
|
||||
|
||||
|
||||
extern "C" _EXPORT BGLRenderer*
|
||||
instantiate_gl_renderer(BGLView* view, ulong options,
|
||||
BGLDispatcher* dispatcher)
|
||||
|
@ -208,7 +213,7 @@ instantiate_gl_renderer(BGLView* view, ulong options,
|
|||
|
||||
|
||||
MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
||||
BGLDispatcher* dispatcher)
|
||||
BGLDispatcher* dispatcher)
|
||||
: BGLRenderer(view, options, dispatcher),
|
||||
fBitmap(NULL),
|
||||
fDirectModeEnabled(false),
|
||||
|
@ -233,7 +238,7 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
fColorSpace = BScreen(GLView()->Window()).ColorSpace();
|
||||
|
||||
// We force single buffering for the time being
|
||||
//options &= !BGL_DOUBLE;
|
||||
options &= !BGL_DOUBLE;
|
||||
|
||||
const GLboolean rgbFlag = ((options & BGL_INDEX) == 0);
|
||||
const GLboolean alphaFlag = ((options & BGL_ALPHA) == BGL_ALPHA);
|
||||
|
@ -242,7 +247,6 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
const GLint depth = (options & BGL_DEPTH) ? 16 : 0;
|
||||
const GLint stencil = (options & BGL_STENCIL) ? 8 : 0;
|
||||
const GLint accum = (options & BGL_ACCUM) ? 16 : 0;
|
||||
const GLint index = (options & BGL_INDEX) ? 32 : 0;
|
||||
const GLint red = rgbFlag ? 8 : 0;
|
||||
const GLint green = rgbFlag ? 8 : 0;
|
||||
const GLint blue = rgbFlag ? 8 : 0;
|
||||
|
@ -251,8 +255,8 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
fOptions = options; // | BGL_INDIRECT;
|
||||
struct dd_function_table functions;
|
||||
|
||||
fVisual = _mesa_create_visual(rgbFlag, dblFlag, stereoFlag, red, green,
|
||||
blue, alpha, index, depth, stencil, accum, accum, accum,
|
||||
fVisual = _mesa_create_visual(dblFlag, stereoFlag, red, green,
|
||||
blue, alpha, depth, stencil, accum, accum, accum,
|
||||
alpha ? accum : 0, 1);
|
||||
|
||||
// Initialize device driver function table
|
||||
|
@ -266,7 +270,13 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
functions.Flush = _Flush;
|
||||
|
||||
// create core context
|
||||
#if HAIKU_MESA_VER <= 708
|
||||
fContext = _mesa_create_context(fVisual, NULL, &functions, this);
|
||||
#else
|
||||
fContext = _mesa_create_context(API_OPENGL, fVisual, NULL,
|
||||
&functions, this);
|
||||
#endif
|
||||
|
||||
if (!fContext) {
|
||||
_mesa_destroy_visual(fVisual);
|
||||
return;
|
||||
|
@ -282,6 +292,7 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
// Use default TCL pipeline
|
||||
TNL_CONTEXT(fContext)->Driver.RunPipeline = _tnl_run_pipeline;
|
||||
|
||||
_mesa_meta_init(fContext);
|
||||
_mesa_enable_sw_extensions(fContext);
|
||||
_mesa_enable_1_3_extensions(fContext);
|
||||
_mesa_enable_1_4_extensions(fContext);
|
||||
|
@ -290,50 +301,86 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
_mesa_enable_2_1_extensions(fContext);
|
||||
|
||||
// create core framebuffer
|
||||
fFrameBuffer = (struct msr_framebuffer*)_mesa_calloc(
|
||||
fFrameBuffer = (struct msr_framebuffer*)calloc(1,
|
||||
sizeof(*fFrameBuffer));
|
||||
_mesa_initialize_framebuffer(&fFrameBuffer->Base, fVisual);
|
||||
_mesa_initialize_window_framebuffer(&fFrameBuffer->base, fVisual);
|
||||
|
||||
fFrontRenderBuffer = (struct msr_renderbuffer*)_mesa_calloc(
|
||||
fFrontRenderBuffer = (struct msr_renderbuffer*)calloc(1,
|
||||
sizeof(*fFrontRenderBuffer));
|
||||
_mesa_init_renderbuffer(&fFrontRenderBuffer->Base, 0);
|
||||
_mesa_init_renderbuffer(&fFrontRenderBuffer->base, 0);
|
||||
|
||||
fFrontRenderBuffer->Base.AllocStorage = _FrontRenderbufferStorage;
|
||||
fFrontRenderBuffer->Base.Data = NULL;
|
||||
fFrontRenderBuffer->Base.InternalFormat = GL_RGBA;
|
||||
fFrontRenderBuffer->Base._BaseFormat = GL_RGBA;
|
||||
fFrontRenderBuffer->Base.DataType = GL_UNSIGNED_BYTE;
|
||||
fFrontRenderBuffer->Base.RedBits = 8 * sizeof(GLubyte);
|
||||
fFrontRenderBuffer->Base.GreenBits = 8 * sizeof(GLubyte);
|
||||
fFrontRenderBuffer->Base.BlueBits = 8 * sizeof(GLubyte);
|
||||
fFrontRenderBuffer->Base.AlphaBits = 8 * sizeof(GLubyte);
|
||||
_SetSpanFuncs(fFrontRenderBuffer, fColorSpace);
|
||||
_mesa_add_renderbuffer(&fFrameBuffer->Base, BUFFER_FRONT_LEFT,
|
||||
&fFrontRenderBuffer->Base);
|
||||
fFrontRenderBuffer->active = true;
|
||||
fFrontRenderBuffer->base.InternalFormat = GL_RGBA;
|
||||
fFrontRenderBuffer->base._BaseFormat = GL_RGBA;
|
||||
fFrontRenderBuffer->base.DataType = GL_UNSIGNED_BYTE;
|
||||
|
||||
if (dblFlag) {
|
||||
fBackRenderBuffer = (struct msr_renderbuffer*)_mesa_calloc(
|
||||
sizeof(*fBackRenderBuffer));
|
||||
_mesa_init_renderbuffer(&fBackRenderBuffer->Base, 0);
|
||||
|
||||
fBackRenderBuffer->Base.AllocStorage = _BackRenderbufferStorage;
|
||||
fBackRenderBuffer->Base.Data = NULL;
|
||||
fBackRenderBuffer->Base.Delete = _DeleteBackBuffer;
|
||||
fBackRenderBuffer->Base.InternalFormat = GL_RGBA;
|
||||
fBackRenderBuffer->Base._BaseFormat = GL_RGBA;
|
||||
fBackRenderBuffer->Base.DataType = GL_UNSIGNED_BYTE;
|
||||
fBackRenderBuffer->Base.RedBits = 8 * sizeof(GLubyte);
|
||||
fBackRenderBuffer->Base.GreenBits = 8 * sizeof(GLubyte);
|
||||
fBackRenderBuffer->Base.BlueBits = 8 * sizeof(GLubyte);
|
||||
fBackRenderBuffer->Base.AlphaBits = 8 * sizeof(GLubyte);
|
||||
_SetSpanFuncs(fBackRenderBuffer, fColorSpace);
|
||||
_mesa_add_renderbuffer(&fFrameBuffer->Base, BUFFER_BACK_LEFT,
|
||||
&fBackRenderBuffer->Base);
|
||||
switch(fColorSpace) {
|
||||
case B_RGB32:
|
||||
#if HAIKU_MESA_VER >= 709
|
||||
// Only in New Mesa
|
||||
fFrontRenderBuffer->base.Format = MESA_FORMAT_XRGB8888;
|
||||
break;
|
||||
#endif
|
||||
case B_RGBA32:
|
||||
fFrontRenderBuffer->base.Format = MESA_FORMAT_ARGB8888;
|
||||
break;
|
||||
case B_RGB24:
|
||||
fFrontRenderBuffer->base.Format = MESA_FORMAT_ARGB8888;
|
||||
break;
|
||||
case B_RGB16:
|
||||
fFrontRenderBuffer->base.Format = MESA_FORMAT_RGB565;
|
||||
break;
|
||||
case B_RGB15:
|
||||
case B_RGBA15:
|
||||
fFrontRenderBuffer->base.Format = MESA_FORMAT_ARGB1555;
|
||||
break;
|
||||
case B_CMAP8:
|
||||
default:
|
||||
fprintf(stderr, "Unsupported screen color space %d\n", fColorSpace);
|
||||
debugger("Unsupported OpenGL color space");
|
||||
break;
|
||||
}
|
||||
|
||||
_mesa_add_soft_renderbuffers(&fFrameBuffer->Base, GL_FALSE,
|
||||
fFrontRenderBuffer->base.AllocStorage = _FrontRenderbufferStorage;
|
||||
fFrontRenderBuffer->base.Data = NULL;
|
||||
|
||||
_SetSpanFuncs(fFrontRenderBuffer, fColorSpace);
|
||||
_mesa_add_renderbuffer(&fFrameBuffer->base, BUFFER_FRONT_LEFT,
|
||||
&fFrontRenderBuffer->base);
|
||||
|
||||
fBackRenderBuffer = (struct msr_renderbuffer*)calloc(1,
|
||||
sizeof(*fBackRenderBuffer));
|
||||
if (dblFlag) {
|
||||
_mesa_init_renderbuffer(&fBackRenderBuffer->base, 0);
|
||||
|
||||
fBackRenderBuffer->active = true;
|
||||
fBackRenderBuffer->base.AllocStorage = _BackRenderbufferStorage;
|
||||
fBackRenderBuffer->base.Data = NULL;
|
||||
fBackRenderBuffer->base.Delete = _DeleteBackBuffer;
|
||||
fBackRenderBuffer->base.InternalFormat
|
||||
= fFrontRenderBuffer->base.InternalFormat;
|
||||
fBackRenderBuffer->base._BaseFormat
|
||||
= fFrontRenderBuffer->base._BaseFormat;
|
||||
fBackRenderBuffer->base.Format = fFrontRenderBuffer->base.Format;
|
||||
|
||||
_SetSpanFuncs(fBackRenderBuffer, fColorSpace);
|
||||
_mesa_add_renderbuffer(&fFrameBuffer->base, BUFFER_BACK_LEFT,
|
||||
&fBackRenderBuffer->base);
|
||||
} else {
|
||||
fBackRenderBuffer->active = false;
|
||||
}
|
||||
|
||||
#if HAIKU_MESA_VER >= 709
|
||||
// New Mesa
|
||||
_swrast_add_soft_renderbuffers(&fFrameBuffer->base, GL_FALSE,
|
||||
fVisual->haveDepthBuffer, fVisual->haveStencilBuffer,
|
||||
fVisual->haveAccumBuffer, alphaFlag, GL_FALSE);
|
||||
#else
|
||||
// Old Mesa
|
||||
_mesa_add_soft_renderbuffers(&fFrameBuffer->base, GL_FALSE,
|
||||
fVisual->haveDepthBuffer, fVisual->haveStencilBuffer,
|
||||
fVisual->haveAccumBuffer, alphaFlag, GL_FALSE);
|
||||
#endif
|
||||
|
||||
BRect bounds = view->Bounds();
|
||||
fWidth = fNewWidth = (GLint)bounds.Width();
|
||||
|
@ -349,6 +396,7 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
MesaSoftwareRenderer::~MesaSoftwareRenderer()
|
||||
{
|
||||
CALLED();
|
||||
|
@ -357,7 +405,7 @@ MesaSoftwareRenderer::~MesaSoftwareRenderer()
|
|||
_tnl_DestroyContext(fContext);
|
||||
_vbo_DestroyContext(fContext);
|
||||
_mesa_destroy_visual(fVisual);
|
||||
_mesa_destroy_framebuffer(&fFrameBuffer->Base);
|
||||
_mesa_destroy_framebuffer(&fFrameBuffer->base);
|
||||
_mesa_destroy_context(fContext);
|
||||
|
||||
free(fInfo);
|
||||
|
@ -372,7 +420,7 @@ MesaSoftwareRenderer::LockGL()
|
|||
CALLED();
|
||||
BGLRenderer::LockGL();
|
||||
|
||||
_mesa_make_current(fContext, &fFrameBuffer->Base, &fFrameBuffer->Base);
|
||||
_mesa_make_current(fContext, &fFrameBuffer->base, &fFrameBuffer->base);
|
||||
|
||||
color_space cs = B_RGBA32;
|
||||
|
||||
|
@ -385,16 +433,17 @@ MesaSoftwareRenderer::LockGL()
|
|||
- fInfo->window_bounds.top + 1;
|
||||
}
|
||||
|
||||
if (fBitmap && cs == fColorSpace && fNewWidth == fWidth
|
||||
&& fNewHeight == fHeight)
|
||||
return;
|
||||
|
||||
if (cs != fColorSpace) {
|
||||
fColorSpace = cs;
|
||||
_SetSpanFuncs(fFrontRenderBuffer, fColorSpace);
|
||||
_SetSpanFuncs(fBackRenderBuffer, fColorSpace);
|
||||
if (fBackRenderBuffer->active)
|
||||
_SetSpanFuncs(fBackRenderBuffer, fColorSpace);
|
||||
}
|
||||
|
||||
if (fBitmap && fNewWidth == fWidth
|
||||
&& fNewHeight == fHeight)
|
||||
return;
|
||||
|
||||
fWidth = fNewWidth;
|
||||
fHeight = fNewHeight;
|
||||
|
||||
|
@ -418,7 +467,7 @@ void
|
|||
MesaSoftwareRenderer::SwapBuffers(bool VSync)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
|
||||
if (!fBitmap)
|
||||
return;
|
||||
|
||||
|
@ -582,12 +631,13 @@ MesaSoftwareRenderer::_AllocateBitmap()
|
|||
+ i * fBitmap->BytesPerRow());
|
||||
}
|
||||
|
||||
_mesa_resize_framebuffer(fContext, &fFrameBuffer->Base, fWidth, fHeight);
|
||||
fFrontRenderBuffer->Base.Data = fBitmap->Bits();
|
||||
fFrontRenderBuffer->Size = fBitmap->BitsLength();
|
||||
fBackRenderBuffer->Size = fBitmap->BitsLength();
|
||||
fFrameBuffer->Width = fWidth;
|
||||
fFrameBuffer->Height = fHeight;
|
||||
_mesa_resize_framebuffer(fContext, &fFrameBuffer->base, fWidth, fHeight);
|
||||
fFrontRenderBuffer->base.Data = fBitmap->Bits();
|
||||
fFrontRenderBuffer->size = fBitmap->BitsLength();
|
||||
if (fBackRenderBuffer->active)
|
||||
fBackRenderBuffer->size = fBitmap->BitsLength();
|
||||
fFrameBuffer->width = fWidth;
|
||||
fFrameBuffer->height = fHeight;
|
||||
}
|
||||
|
||||
|
||||
|
@ -595,7 +645,7 @@ MesaSoftwareRenderer::_AllocateBitmap()
|
|||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::_Error(GLcontext* ctx)
|
||||
MesaSoftwareRenderer::_Error(gl_context* ctx)
|
||||
{
|
||||
MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
|
||||
if (mr && mr->GLView())
|
||||
|
@ -604,17 +654,17 @@ MesaSoftwareRenderer::_Error(GLcontext* ctx)
|
|||
|
||||
|
||||
const GLubyte*
|
||||
MesaSoftwareRenderer::_GetString(GLcontext* ctx, GLenum name)
|
||||
MesaSoftwareRenderer::_GetString(gl_context* ctx, GLenum name)
|
||||
{
|
||||
switch (name) {
|
||||
case GL_VENDOR:
|
||||
return (const GLubyte*) "Mesa Project";
|
||||
case GL_RENDERER: {
|
||||
static char buffer[256] = { '\0' };
|
||||
|
||||
if (!buffer[0]) {
|
||||
// Let's build an renderer string
|
||||
// TODO: add SVN revision
|
||||
strncat(buffer, "Haiku's Mesa " MESA_VERSION_STRING
|
||||
" Software Renderer", sizeof(buffer));
|
||||
strncat(buffer, "Software Rasterizer", sizeof(buffer));
|
||||
|
||||
// Append any CPU-specific information.
|
||||
#ifdef USE_X86_ASM
|
||||
|
@ -661,7 +711,7 @@ MesaSoftwareRenderer::_GetString(GLcontext* ctx, GLenum name)
|
|||
#endif
|
||||
|
||||
}
|
||||
return (const GLubyte *) buffer;
|
||||
return (const GLubyte*) buffer;
|
||||
}
|
||||
default:
|
||||
// Let core library handle all other cases
|
||||
|
@ -671,22 +721,22 @@ MesaSoftwareRenderer::_GetString(GLcontext* ctx, GLenum name)
|
|||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::_Viewport(GLcontext* ctx, GLint x, GLint y, GLsizei w,
|
||||
MesaSoftwareRenderer::_Viewport(gl_context* ctx, GLint x, GLint y, GLsizei w,
|
||||
GLsizei h)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
GLframebuffer* draw = ctx->WinSysDrawBuffer;
|
||||
GLframebuffer* read = ctx->WinSysReadBuffer;
|
||||
gl_framebuffer* draw = ctx->WinSysDrawBuffer;
|
||||
gl_framebuffer* read = ctx->WinSysReadBuffer;
|
||||
struct msr_framebuffer* msr = msr_framebuffer(draw);
|
||||
|
||||
_mesa_resize_framebuffer(ctx, draw, msr->Width, msr->Height);
|
||||
_mesa_resize_framebuffer(ctx, read, msr->Width, msr->Height);
|
||||
_mesa_resize_framebuffer(ctx, draw, msr->width, msr->height);
|
||||
_mesa_resize_framebuffer(ctx, read, msr->width, msr->height);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::_UpdateState(GLcontext* ctx, GLuint new_state)
|
||||
MesaSoftwareRenderer::_UpdateState(gl_context* ctx, GLuint new_state)
|
||||
{
|
||||
if (!ctx)
|
||||
return;
|
||||
|
@ -700,7 +750,7 @@ MesaSoftwareRenderer::_UpdateState(GLcontext* ctx, GLuint new_state)
|
|||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::_ClearFront(GLcontext* ctx)
|
||||
MesaSoftwareRenderer::_ClearFront(gl_context* ctx)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
|
@ -745,32 +795,36 @@ MesaSoftwareRenderer::_ClearFront(GLcontext* ctx)
|
|||
|
||||
|
||||
GLboolean
|
||||
MesaSoftwareRenderer::_FrontRenderbufferStorage(GLcontext* ctx,
|
||||
MesaSoftwareRenderer::_FrontRenderbufferStorage(gl_context* ctx,
|
||||
struct gl_renderbuffer* render, GLenum internalFormat,
|
||||
GLuint width, GLuint height)
|
||||
{
|
||||
render->Data = NULL;
|
||||
render->Width = width;
|
||||
render->Height = height;
|
||||
#if HAIKU_MESA_VER >= 712
|
||||
render->RowStride = width;
|
||||
#endif
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
GLboolean
|
||||
MesaSoftwareRenderer::_BackRenderbufferStorage(GLcontext* ctx,
|
||||
MesaSoftwareRenderer::_BackRenderbufferStorage(gl_context* ctx,
|
||||
struct gl_renderbuffer* render, GLenum internalFormat,
|
||||
GLuint width, GLuint height)
|
||||
{
|
||||
struct msr_renderbuffer* mrb = msr_renderbuffer(render);
|
||||
_mesa_free(render->Data);
|
||||
free(render->Data);
|
||||
_FrontRenderbufferStorage(ctx, render, internalFormat, width, height);
|
||||
render->Data = _mesa_malloc(mrb->Size);
|
||||
render->Data = malloc(mrb->size);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::_Flush(GLcontext* ctx)
|
||||
MesaSoftwareRenderer::_Flush(gl_context* ctx)
|
||||
{
|
||||
CALLED();
|
||||
MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
|
||||
|
@ -787,60 +841,75 @@ void
|
|||
MesaSoftwareRenderer::_SetSpanFuncs(
|
||||
struct msr_renderbuffer* buffer, color_space colorSpace)
|
||||
{
|
||||
if (!buffer->active)
|
||||
return;
|
||||
|
||||
switch (colorSpace) {
|
||||
case B_RGBA32:
|
||||
buffer->Base.GetRow = get_row_RGBA32;
|
||||
buffer->Base.GetValues = get_values_RGBA32;
|
||||
buffer->Base.PutRow = put_row_RGBA32;
|
||||
buffer->Base.PutRowRGB = put_row_rgb_RGBA32;
|
||||
buffer->Base.PutMonoRow = put_mono_row_RGBA32;
|
||||
buffer->Base.PutValues = put_values_RGBA32;
|
||||
buffer->Base.PutMonoValues = put_mono_values_RGBA32;
|
||||
buffer->base.GetRow = get_row_RGBA32;
|
||||
buffer->base.GetValues = get_values_RGBA32;
|
||||
buffer->base.PutRow = put_row_RGBA32;
|
||||
buffer->base.PutValues = put_values_RGBA32;
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
buffer->base.PutRowRGB = put_row_rgb_RGBA32;
|
||||
buffer->base.PutMonoRow = put_mono_row_RGBA32;
|
||||
buffer->base.PutMonoValues = put_values_RGBA32;
|
||||
#endif
|
||||
break;
|
||||
case B_RGB32:
|
||||
buffer->Base.GetRow = get_row_RGB32;
|
||||
buffer->Base.GetValues = get_values_RGB32;
|
||||
buffer->Base.PutRow = put_row_RGB32;
|
||||
buffer->Base.PutRowRGB = put_row_rgb_RGB32;
|
||||
buffer->Base.PutMonoRow = put_mono_row_RGB32;
|
||||
buffer->Base.PutValues = put_values_RGB32;
|
||||
buffer->Base.PutMonoValues = put_mono_values_RGB32;
|
||||
buffer->base.GetRow = get_row_RGB32;
|
||||
buffer->base.GetValues = get_values_RGB32;
|
||||
buffer->base.PutRow = put_row_RGB32;
|
||||
buffer->base.PutValues = put_values_RGB32;
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
buffer->base.PutRowRGB = put_row_rgb_RGB32;
|
||||
buffer->base.PutMonoRow = put_mono_row_RGB32;
|
||||
buffer->base.PutMonoValues = put_values_RGB32;
|
||||
#endif
|
||||
break;
|
||||
case B_RGB24:
|
||||
buffer->Base.GetRow = get_row_RGB24;
|
||||
buffer->Base.GetValues = get_values_RGB24;
|
||||
buffer->Base.PutRow = put_row_RGB24;
|
||||
buffer->Base.PutRowRGB = put_row_rgb_RGB24;
|
||||
buffer->Base.PutMonoRow = put_mono_row_RGB24;
|
||||
buffer->Base.PutValues = put_values_RGB24;
|
||||
buffer->Base.PutMonoValues = put_mono_values_RGB24;
|
||||
buffer->base.GetRow = get_row_RGB24;
|
||||
buffer->base.GetValues = get_values_RGB24;
|
||||
buffer->base.PutRow = put_row_RGB24;
|
||||
buffer->base.PutValues = put_values_RGB24;
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
buffer->base.PutRowRGB = put_row_rgb_RGB24;
|
||||
buffer->base.PutMonoRow = put_mono_row_RGB24;
|
||||
buffer->base.PutMonoValues = put_values_RGB24;
|
||||
#endif
|
||||
break;
|
||||
case B_RGB16:
|
||||
buffer->Base.GetRow = get_row_RGB16;
|
||||
buffer->Base.GetValues = get_values_RGB16;
|
||||
buffer->Base.PutRow = put_row_RGB16;
|
||||
buffer->Base.PutRowRGB = put_row_rgb_RGB16;
|
||||
buffer->Base.PutMonoRow = put_mono_row_RGB16;
|
||||
buffer->Base.PutValues = put_values_RGB16;
|
||||
buffer->Base.PutMonoValues = put_mono_values_RGB16;
|
||||
buffer->base.GetRow = get_row_RGB16;
|
||||
buffer->base.GetValues = get_values_RGB16;
|
||||
buffer->base.PutRow = put_row_RGB16;
|
||||
buffer->base.PutValues = put_values_RGB16;
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
buffer->base.PutRowRGB = put_row_rgb_RGB16;
|
||||
buffer->base.PutMonoRow = put_mono_row_RGB16;
|
||||
buffer->base.PutMonoValues = put_values_RGB16;
|
||||
#endif
|
||||
break;
|
||||
case B_RGB15:
|
||||
buffer->Base.GetRow = get_row_RGB15;
|
||||
buffer->Base.GetValues = get_values_RGB15;
|
||||
buffer->Base.PutRow = put_row_RGB15;
|
||||
buffer->Base.PutRowRGB = put_row_rgb_RGB15;
|
||||
buffer->Base.PutMonoRow = put_mono_row_RGB15;
|
||||
buffer->Base.PutValues = put_values_RGB15;
|
||||
buffer->Base.PutMonoValues = put_mono_values_RGB15;
|
||||
buffer->base.GetRow = get_row_RGB15;
|
||||
buffer->base.GetValues = get_values_RGB15;
|
||||
buffer->base.PutRow = put_row_RGB15;
|
||||
buffer->base.PutValues = put_values_RGB15;
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
buffer->base.PutRowRGB = put_row_rgb_RGB15;
|
||||
buffer->base.PutMonoRow = put_mono_row_RGB15;
|
||||
buffer->base.PutMonoValues = put_values_RGB15;
|
||||
#endif
|
||||
break;
|
||||
case B_CMAP8:
|
||||
buffer->Base.GetRow = get_row_CMAP8;
|
||||
buffer->Base.GetValues = get_values_CMAP8;
|
||||
buffer->Base.PutRow = put_row_CMAP8;
|
||||
buffer->Base.PutRowRGB = put_row_rgb_CMAP8;
|
||||
buffer->Base.PutMonoRow = put_mono_row_CMAP8;
|
||||
buffer->Base.PutValues = put_values_CMAP8;
|
||||
buffer->Base.PutMonoValues = put_mono_values_CMAP8;
|
||||
buffer->base.GetRow = get_row_CMAP8;
|
||||
buffer->base.GetValues = get_values_CMAP8;
|
||||
buffer->base.PutRow = put_row_CMAP8;
|
||||
buffer->base.PutValues = put_values_CMAP8;
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
buffer->base.PutRowRGB = put_row_rgb_CMAP8;
|
||||
buffer->base.PutMonoRow = put_mono_row_CMAP8;
|
||||
buffer->base.PutMonoValues = put_values_CMAP8;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported screen color space %d\n", fColorSpace);
|
||||
|
@ -853,8 +922,8 @@ MesaSoftwareRenderer::_SetSpanFuncs(
|
|||
void
|
||||
MesaSoftwareRenderer::_DeleteBackBuffer(struct gl_renderbuffer* rb)
|
||||
{
|
||||
_mesa_free(rb->Data);
|
||||
_mesa_free(rb);
|
||||
free(rb->Data);
|
||||
free(rb);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,12 +19,26 @@
|
|||
#include "GLRenderer.h"
|
||||
|
||||
extern "C" {
|
||||
#include "main/version.h"
|
||||
#define HAIKU_MESA_VER (MESA_MAJOR * 100) + MESA_MINOR
|
||||
|
||||
#include "context.h"
|
||||
|
||||
#if HAIKU_MESA_VER >= 712
|
||||
#include "swrast/s_chan.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if HAIKU_MESA_VER <= 711
|
||||
#define gl_context GLcontext
|
||||
#define gl_config GLvisual
|
||||
#endif
|
||||
|
||||
|
||||
struct msr_renderbuffer {
|
||||
struct gl_renderbuffer Base;
|
||||
uint32 Size;
|
||||
struct gl_renderbuffer base;
|
||||
uint32 size;
|
||||
bool active;
|
||||
};
|
||||
|
||||
|
||||
|
@ -36,9 +50,9 @@ msr_renderbuffer(struct gl_renderbuffer* rb)
|
|||
|
||||
|
||||
struct msr_framebuffer {
|
||||
struct gl_framebuffer Base;
|
||||
uint32 Width;
|
||||
uint32 Height;
|
||||
struct gl_framebuffer base;
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
};
|
||||
|
||||
|
||||
|
@ -48,8 +62,10 @@ msr_framebuffer(struct gl_framebuffer* rb)
|
|||
return (struct msr_framebuffer*)rb;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class MesaSoftwareRenderer : public BGLRenderer {
|
||||
public:
|
||||
MesaSoftwareRenderer(BGLView* view,
|
||||
|
@ -72,21 +88,21 @@ public:
|
|||
virtual void DirectConnected(direct_buffer_info* info);
|
||||
|
||||
private:
|
||||
static void _Error(GLcontext* ctx);
|
||||
static const GLubyte* _GetString(GLcontext* ctx, GLenum name);
|
||||
static void _Viewport(GLcontext* ctx, GLint x, GLint y,
|
||||
static void _Error(gl_context* ctx);
|
||||
static const GLubyte* _GetString(gl_context* ctx, GLenum name);
|
||||
static void _Viewport(gl_context* ctx, GLint x, GLint y,
|
||||
GLsizei w, GLsizei h);
|
||||
static void _UpdateState(GLcontext* ctx, GLuint newState);
|
||||
static void _ClearFront(GLcontext* ctx);
|
||||
static GLboolean _FrontRenderbufferStorage(GLcontext* ctx,
|
||||
static void _UpdateState(gl_context* ctx, GLuint newState);
|
||||
static void _ClearFront(gl_context* ctx);
|
||||
static GLboolean _FrontRenderbufferStorage(gl_context* ctx,
|
||||
struct gl_renderbuffer* render,
|
||||
GLenum internalFormat,
|
||||
GLuint width, GLuint height);
|
||||
static GLboolean _BackRenderbufferStorage(GLcontext* ctx,
|
||||
static GLboolean _BackRenderbufferStorage(gl_context* ctx,
|
||||
struct gl_renderbuffer* render,
|
||||
GLenum internalFormat,
|
||||
GLuint width, GLuint height);
|
||||
static void _Flush(GLcontext *ctx);
|
||||
static void _Flush(gl_context *ctx);
|
||||
void _SetSpanFuncs(struct msr_renderbuffer* buffer,
|
||||
color_space colorSpace);
|
||||
static void _DeleteBackBuffer(struct gl_renderbuffer* rb);
|
||||
|
@ -100,8 +116,8 @@ private:
|
|||
BLocker fInfoLocker;
|
||||
ulong fOptions;
|
||||
|
||||
GLcontext* fContext;
|
||||
GLvisual* fVisual;
|
||||
gl_context* fContext;
|
||||
gl_config* fVisual;
|
||||
struct msr_framebuffer* fFrameBuffer;
|
||||
struct msr_renderbuffer* fFrontRenderBuffer;
|
||||
struct msr_renderbuffer* fBackRenderBuffer;
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
SubDir HAIKU_TOP src add-ons screen_savers flurry ;
|
||||
SubDirSysHdrs $(HAIKU_MESA_HEADERS) ;
|
||||
|
||||
# For GCC2
|
||||
if $(HAIKU_GCC_VERSION[1]) < 3 {
|
||||
SubDirC++Flags --no-warnings ;
|
||||
}
|
||||
|
||||
|
||||
AddResources Message : Flurry.rdef ;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
SubDir HAIKU_TOP src apps glteapot ;
|
||||
SubDirSysHdrs $(HAIKU_MESA_HEADERS) ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
# For GCC2
|
||||
if $(HAIKU_GCC_VERSION[1]) < 3 {
|
||||
SubDirC++Flags --no-warnings ;
|
||||
}
|
||||
|
||||
|
||||
Application GLTeapot :
|
||||
FPS.cpp
|
||||
GLObject.cpp
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define UTIL_H
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include "error.h"
|
||||
|
||||
template <class contents>
|
||||
|
|
|
@ -32,13 +32,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
*
|
||||
*/
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include "glheader.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "glapi.h"
|
||||
#if __GNUC__ > 2
|
||||
// New Mesa
|
||||
#include "glapi_priv.h"
|
||||
#include "glapitable.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: this file portion implements C-based dispatch of the OpenGL entrypoints
|
||||
|
@ -66,7 +67,9 @@ extern "C" {
|
|||
return (dispatch->func) args
|
||||
|
||||
|
||||
#if __GNUC__ > 2
|
||||
#include "glapitemp.h"
|
||||
#endif
|
||||
|
||||
#endif /* USE_X86_ASM */
|
||||
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <GL/gl.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include "glheader.h"
|
||||
|
||||
extern "C" {
|
||||
#include "glapi.h"
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <DirectWindow.h>
|
||||
|
|
|
@ -3,61 +3,50 @@ SubDir HAIKU_TOP src kits opengl ;
|
|||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UsePrivateHeaders interface ;
|
||||
UseLibraryHeaders mesa ;
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
local sources =
|
||||
GLView.cpp
|
||||
GLDispatcher.cpp
|
||||
GLRenderer.cpp
|
||||
GLRendererRoster.cpp
|
||||
;
|
||||
|
||||
|
||||
if $(TARGET_PLATFORM) != haiku {
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ;
|
||||
# We need our public GL headers also when not compiling for Haiku.
|
||||
}
|
||||
|
||||
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa main ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa glapi ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa math ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa tnl ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa shader ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa swrast ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa swrast_setup ] ;
|
||||
SubDirSysHdrs $(HAIKU_MESA_HEADERS) ;
|
||||
Includes [ FGristFiles $(sources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ;
|
||||
|
||||
{
|
||||
local defines ;
|
||||
defines = BEOS_THREADS GNU_ASSEMBLER ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) include ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa main ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mapi ] ;
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mapi glapi ] ;
|
||||
|
||||
if $(TARGET_ARCH) = x86 {
|
||||
defines += USE_X86_ASM USE_MMX_ASM USE_3DNOW_ASM USE_SSE_ASM ;
|
||||
} else if $(TARGET_ARCH) = ppc {
|
||||
# Not yet supported, as current Mesa3D PPC assembly is Linux-dependent!
|
||||
# defines += USE_PPC_ASM ;
|
||||
} else if $(TARGET_ARCH) = sparc {
|
||||
defines += USE_SPARC_ASM ;
|
||||
}
|
||||
# For older versions of Mesa
|
||||
UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa glapi ] ;
|
||||
|
||||
defines = [ FDefines $(defines) ] ;
|
||||
SubDirCcFlags $(defines) ;
|
||||
SubDirC++Flags $(defines) ;
|
||||
SubDirAsFlags $(defines) ;
|
||||
LINKFLAGS on libGL.so = [ on libGL.so return $(LINKFLAGS) ]
|
||||
-Xlinker --strip-debug -Xlinker --whole-archive -Xlinker -zmuldefs ;
|
||||
|
||||
# For GCC2
|
||||
if $(HAIKU_GCC_VERSION[1]) < 3 {
|
||||
SubDirC++Flags --no-warnings ;
|
||||
}
|
||||
|
||||
|
||||
SharedLibrary libGL.so :
|
||||
GLView.cpp
|
||||
GLDispatcher.cpp
|
||||
GLRenderer.cpp
|
||||
GLRendererRoster.cpp
|
||||
:
|
||||
SharedLibrary libGL.so : $(sources) :
|
||||
|
||||
# Mesa GL API dispatching code
|
||||
<mesa>glapi-dispatching.o
|
||||
# Mesa libraries (from Mesa optional package):
|
||||
$(HAIKU_MESA_LIBS)
|
||||
|
||||
# GLU API is included in libGL.so under BeOS R5, not a separate libglu.so library
|
||||
<opengl>sgi-glu.o
|
||||
|
||||
# GLUT API is included in libGL.so under Haiku, not a separate libglut.so library
|
||||
<opengl>glut.o
|
||||
|
||||
# External libs:
|
||||
be
|
||||
game # BWindowScreen needed by BGLScreen stub class
|
||||
# External libraries:
|
||||
be
|
||||
game # BWindowScreen needed by BGLScreen stub class
|
||||
$(TARGET_LIBSTDC++)
|
||||
;
|
||||
|
|
|
@ -9,6 +9,7 @@ SubInclude HAIKU_TOP src libs edit ;
|
|||
SubInclude HAIKU_TOP src libs expat ;
|
||||
SubInclude HAIKU_TOP src libs fluidsynth ;
|
||||
SubInclude HAIKU_TOP src libs freetype2 ;
|
||||
SubInclude HAIKU_TOP src libs glut ;
|
||||
SubInclude HAIKU_TOP src libs gnu ;
|
||||
SubInclude HAIKU_TOP src libs icon ;
|
||||
SubInclude HAIKU_TOP src libs iconv ;
|
||||
|
@ -17,7 +18,6 @@ SubInclude HAIKU_TOP src libs libtelnet ;
|
|||
SubInclude HAIKU_TOP src libs linprog ;
|
||||
SubInclude HAIKU_TOP src libs lp_solve ;
|
||||
SubInclude HAIKU_TOP src libs mapm ;
|
||||
SubInclude HAIKU_TOP src libs mesa ;
|
||||
SubInclude HAIKU_TOP src libs ncurses ;
|
||||
SubInclude HAIKU_TOP src libs pdflib ;
|
||||
SubInclude HAIKU_TOP src libs png ;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SubDir HAIKU_TOP src libs mesa glut ;
|
||||
SubDir HAIKU_TOP src libs glut ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
SubDir HAIKU_TOP src libs mesa ;
|
||||
|
||||
SubInclude HAIKU_TOP src libs mesa glu ;
|
||||
SubInclude HAIKU_TOP src libs mesa glut ;
|
||||
SubInclude HAIKU_TOP src libs mesa mesa ;
|
|
@ -1,124 +0,0 @@
|
|||
SubDir HAIKU_TOP src libs mesa glu ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
if $(TARGET_PLATFORM) != haiku {
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ;
|
||||
# We need our public GL headers also when not compiling for Haiku.
|
||||
}
|
||||
|
||||
UseHeaders [ FDirName $(SUBDIR) include ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) libnurbs interface ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) libnurbs internals ] ;
|
||||
UseHeaders [ FDirName $(SUBDIR) libnurbs nurbtess ] ;
|
||||
|
||||
SubDirCcFlags -DNDEBUG -DLIBRARYBUILD ;
|
||||
SubDirC++Flags -DNDEBUG -DLIBRARYBUILD ;
|
||||
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) libutil ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) libtess ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) libnurbs interface ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) libnurbs internals ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) libnurbs nurbtess ] ;
|
||||
|
||||
MergeObject <opengl>sgi-glu.o :
|
||||
|
||||
# libutil
|
||||
error.c
|
||||
glue.c
|
||||
mipmap.c
|
||||
project.c
|
||||
quad.c
|
||||
registry.c
|
||||
|
||||
# libtess
|
||||
dict.c
|
||||
geom.c
|
||||
memalloc.c
|
||||
mesh.c
|
||||
normal.c
|
||||
priorityq.c
|
||||
render.c
|
||||
sweep.c
|
||||
tess.c
|
||||
tessmono.c
|
||||
|
||||
# libnurbs/interface
|
||||
bezierEval.cc
|
||||
bezierPatch.cc
|
||||
bezierPatchMesh.cc
|
||||
glcurveval.cc
|
||||
glinterface.cc
|
||||
glrenderer.cc
|
||||
glsurfeval.cc
|
||||
incurveeval.cc
|
||||
insurfeval.cc
|
||||
|
||||
# libnurbs/internals
|
||||
arc.cc
|
||||
arcsorter.cc
|
||||
arctess.cc
|
||||
backend.cc
|
||||
basiccrveval.cc
|
||||
basicsurfeval.cc
|
||||
bin.cc
|
||||
bufpool.cc
|
||||
cachingeval.cc
|
||||
ccw.cc
|
||||
coveandtiler.cc
|
||||
curve.cc
|
||||
curvelist.cc
|
||||
curvesub.cc
|
||||
dataTransform.cc
|
||||
displaylist.cc
|
||||
flist.cc
|
||||
flistsorter.cc
|
||||
hull.cc
|
||||
intersect.cc
|
||||
knotvector.cc
|
||||
mapdesc.cc
|
||||
mapdescv.cc
|
||||
maplist.cc
|
||||
mesher.cc
|
||||
monoTriangulationBackend.cc
|
||||
monotonizer.cc
|
||||
mycode.cc
|
||||
nurbsinterfac.cc
|
||||
nurbstess.cc
|
||||
patch.cc
|
||||
patchlist.cc
|
||||
quilt.cc
|
||||
reader.cc
|
||||
renderhints.cc
|
||||
slicer.cc
|
||||
sorter.cc
|
||||
splitarcs.cc
|
||||
subdivider.cc
|
||||
tobezier.cc
|
||||
trimline.cc
|
||||
trimregion.cc
|
||||
trimvertpool.cc
|
||||
uarray.cc
|
||||
varray.cc
|
||||
|
||||
# libnurbs/nurbtess
|
||||
directedLine.cc
|
||||
gridWrap.cc
|
||||
monoChain.cc
|
||||
monoPolyPart.cc
|
||||
monoTriangulation.cc
|
||||
partitionX.cc
|
||||
partitionY.cc
|
||||
polyDBG.cc
|
||||
polyUtil.cc
|
||||
primitiveStream.cc
|
||||
quicksort.cc
|
||||
rectBlock.cc
|
||||
sampleComp.cc
|
||||
sampleCompBot.cc
|
||||
sampleCompRight.cc
|
||||
sampleCompTop.cc
|
||||
sampleMonoPoly.cc
|
||||
sampledLine.cc
|
||||
searchTree.cc
|
||||
;
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
** gluos.h - operating system dependencies for GLU
|
||||
**
|
||||
*/
|
||||
#ifdef __VMS
|
||||
#ifdef __cplusplus
|
||||
#pragma message disable nocordel
|
||||
#pragma message disable codeunreachable
|
||||
#pragma message disable codcauunr
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/* Disable *lots* of warnings to get a clean build. I can't be bothered fixing the
|
||||
* code at the moment, as it is pretty ugly.
|
||||
*/
|
||||
#pragma warning 7 10
|
||||
#pragma warning 13 10
|
||||
#pragma warning 14 10
|
||||
#pragma warning 367 10
|
||||
#pragma warning 379 10
|
||||
#pragma warning 726 10
|
||||
#pragma warning 836 10
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_FOR_SNAP
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#include <stdlib.h> /* For _MAX_PATH definition */
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOGDI
|
||||
#define NOIME
|
||||
#define NOMINMAX
|
||||
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#ifndef STRICT
|
||||
#define STRICT 1
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* Disable warnings */
|
||||
#pragma warning(disable : 4101)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4761)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1300
|
||||
#pragma comment(linker, "/OPT:NOWIN98")
|
||||
#endif
|
||||
|
||||
#elif defined(__OS2__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#define WINGDIAPI
|
||||
|
||||
#else
|
||||
|
||||
/* Disable Microsoft-specific keywords */
|
||||
#define GLAPIENTRY
|
||||
#define WINGDIAPI
|
||||
|
||||
#endif
|
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "bezierEval.h"
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#pragma warning 14 10
|
||||
#endif
|
||||
|
||||
#define TOLERANCE 0.0001
|
||||
|
||||
#ifndef MAX_ORDER
|
||||
#define MAX_ORDER 16
|
||||
#endif
|
||||
|
||||
#ifndef MAX_DIMENSION
|
||||
#define MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
static void normalize(float vec[3]);
|
||||
static void crossProduct(float x[3], float y[3], float ret[3]);
|
||||
#if 0 // UNUSED
|
||||
static void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
|
||||
#endif
|
||||
|
||||
static float binomialCoefficients[8][8] = {
|
||||
{1,0,0,0,0,0,0,0},
|
||||
{1,1,0,0,0,0,0,0},
|
||||
{1,2,1,0,0,0,0,0},
|
||||
{1,3,3,1,0,0,0,0},
|
||||
{1,4,6,4,1,0,0,0},
|
||||
{1,5,10,10,5,1,0,0},
|
||||
{1,6,15,20,15,6,1,0},
|
||||
{1,7,21,35,35,21,7,1}
|
||||
};
|
||||
|
||||
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
|
||||
{
|
||||
float uprime = (u-u0)/(u1-u0);
|
||||
float *ctlptr = ctlpoints;
|
||||
float oneMinusX = 1.0f-uprime;
|
||||
float XPower = 1.0f;
|
||||
|
||||
int i,k;
|
||||
for(k=0; k<dimension; k++)
|
||||
retpoint[k] = (*(ctlptr + k));
|
||||
|
||||
for(i=1; i<order; i++){
|
||||
ctlptr += stride;
|
||||
XPower *= uprime;
|
||||
for(k=0; k<dimension; k++) {
|
||||
retpoint[k] = retpoint[k]*oneMinusX + ctlptr[k]* binomialCoefficients[order-1][i] * XPower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0 // UNUSED
|
||||
/*order = degree +1 >=1.
|
||||
*/
|
||||
void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
|
||||
{
|
||||
float uprime = (u-u0)/(u1-u0);
|
||||
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
|
||||
float* ctlptr = ctlpoints;
|
||||
int r, i,j;
|
||||
for(i=0; i<order; i++) {
|
||||
for(j=0; j<dimension; j++)
|
||||
buf[0][i][j] = ctlptr[j];
|
||||
ctlptr += stride;
|
||||
}
|
||||
for(r=1; r<order; r++){
|
||||
for(i=0; i<order-r; i++) {
|
||||
for(j=0; j<dimension; j++)
|
||||
buf[r][i][j] = (1-uprime)*buf[r-1][i][j] + uprime*buf[r-1][i+1][j];
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0; j<dimension; j++)
|
||||
retpoint[j] = buf[order-1][0][j];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*order = degree +1 >=1.
|
||||
*/
|
||||
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
|
||||
{
|
||||
int i,k;
|
||||
float width = u1-u0;
|
||||
float *ctlptr = ctlpoints;
|
||||
|
||||
float buf[MAX_ORDER][MAX_DIMENSION];
|
||||
if(order == 1){
|
||||
for(k=0; k<dimension; k++)
|
||||
retDer[k]=0;
|
||||
}
|
||||
for(i=0; i<order-1; i++){
|
||||
for(k=0; k<dimension; k++) {
|
||||
buf[i][k] = (ctlptr[stride+k] - ctlptr[k])*(order-1)/width;
|
||||
}
|
||||
ctlptr += stride;
|
||||
}
|
||||
|
||||
bezierCurveEval(u0, u1, order-1, (float*) buf, MAX_DIMENSION, dimension, u, retDer);
|
||||
}
|
||||
|
||||
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
|
||||
{
|
||||
int i,k,r;
|
||||
float *ctlptr = ctlpoints;
|
||||
float width=u1-u0;
|
||||
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
|
||||
if(der<0) der=0;
|
||||
for(i=0; i<order; i++){
|
||||
for(k=0; k<dimension; k++){
|
||||
buf[0][i][k] = ctlptr[k];
|
||||
}
|
||||
ctlptr += stride;
|
||||
}
|
||||
|
||||
|
||||
for(r=1; r<=der; r++){
|
||||
for(i=0; i<order-r; i++){
|
||||
for(k=0; k<dimension; k++){
|
||||
buf[r][i][k] = (buf[r-1][i+1][k] - buf[r-1][i][k])*(order-r)/width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bezierCurveEval(u0, u1, order-der, (float *) (buf[der]), MAX_DIMENSION, dimension, u, retDer);
|
||||
}
|
||||
|
||||
/*the Bezier bivarite polynomial is:
|
||||
* sum[i:0,uorder-1][j:0,vorder-1] { ctlpoints[i*ustride+j*vstride] * B(i)*B(j)
|
||||
* where B(i) and B(j) are basis functions
|
||||
*/
|
||||
void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
|
||||
{
|
||||
int i;
|
||||
float newPoints[MAX_ORDER][MAX_DIMENSION];
|
||||
|
||||
for(i=0; i<uorder; i++){
|
||||
|
||||
bezierCurveEvalDerGen(vder, v0, v1, vorder, ctlpoints+ustride*i, vstride, dimension, v, newPoints[i]);
|
||||
|
||||
}
|
||||
|
||||
bezierCurveEvalDerGen(uder, u0, u1, uorder, (float *) newPoints, MAX_DIMENSION, dimension, u, ret);
|
||||
}
|
||||
|
||||
|
||||
/*division by w is performed*/
|
||||
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
|
||||
{
|
||||
bezierSurfEvalDerGen(0, 0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, ret);
|
||||
if(dimension == 4) /*homogeneous*/{
|
||||
ret[0] /= ret[3];
|
||||
ret[1] /= ret[3];
|
||||
ret[2] /= ret[3];
|
||||
}
|
||||
}
|
||||
|
||||
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[])
|
||||
{
|
||||
float partialU[4];
|
||||
float partialV[4];
|
||||
assert(dimension>=3 && dimension <=4);
|
||||
bezierSurfEvalDerGen(1,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialU);
|
||||
bezierSurfEvalDerGen(0,1, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialV);
|
||||
|
||||
if(dimension == 3){/*inhomogeneous*/
|
||||
crossProduct(partialU, partialV, retNormal);
|
||||
|
||||
normalize(retNormal);
|
||||
|
||||
return;
|
||||
}
|
||||
else { /*homogeneous*/
|
||||
float val[4]; /*the point coordinates (without derivative)*/
|
||||
float newPartialU[MAX_DIMENSION];
|
||||
float newPartialV[MAX_DIMENSION];
|
||||
int i;
|
||||
bezierSurfEvalDerGen(0,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, val);
|
||||
|
||||
for(i=0; i<=2; i++){
|
||||
newPartialU[i] = partialU[i] * val[3] - val[i] * partialU[3];
|
||||
newPartialV[i] = partialV[i] * val[3] - val[i] * partialV[3];
|
||||
}
|
||||
crossProduct(newPartialU, newPartialV, retNormal);
|
||||
normalize(retNormal);
|
||||
}
|
||||
}
|
||||
|
||||
/*if size is 0, then nothing is done*/
|
||||
static void normalize(float vec[3])
|
||||
{
|
||||
float size = (float)sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
|
||||
|
||||
if(size < TOLERANCE)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Warning: in oglBSpline.c normal is 0\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else {
|
||||
vec[0] = vec[0]/size;
|
||||
vec[1] = vec[1]/size;
|
||||
vec[2] = vec[2]/size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void crossProduct(float x[3], float y[3], float ret[3])
|
||||
{
|
||||
ret[0] = x[1]*y[2] - y[1]*x[2];
|
||||
ret[1] = x[2]*y[0] - y[2]*x[0];
|
||||
ret[2] = x[0]*y[1] - y[0]*x[1];
|
||||
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _BEZIEREVAL_H
|
||||
#define _BEZIEREVAL_H
|
||||
|
||||
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
|
||||
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
|
||||
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
|
||||
|
||||
|
||||
void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[]);
|
||||
|
||||
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[]);
|
||||
|
||||
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[]);
|
||||
|
||||
|
||||
#endif
|
|
@ -1,206 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <GL/glu.h> /*for drawing bzier patch*/
|
||||
#include "bezierPatch.h"
|
||||
#include "bezierEval.h"
|
||||
|
||||
/*
|
||||
*allocate an instance of bezierPatch. The control points are unknown. But
|
||||
*the space of this array is allocated with size of
|
||||
* uorder*vorder*dimension
|
||||
*
|
||||
*/
|
||||
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension)
|
||||
{
|
||||
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
|
||||
assert(ret);
|
||||
ret->umin = umin;
|
||||
ret->vmin = vmin;
|
||||
ret->umax = umax;
|
||||
ret->vmax = vmax;
|
||||
ret->uorder = uorder;
|
||||
ret->vorder = vorder;
|
||||
ret->dimension = dimension;
|
||||
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
|
||||
assert(ret->ctlpoints);
|
||||
|
||||
ret->next = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension, int ustride, int vstride, float* ctlpoints)
|
||||
{
|
||||
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
|
||||
assert(ret);
|
||||
ret->umin = umin;
|
||||
ret->vmin = vmin;
|
||||
ret->umax = umax;
|
||||
ret->vmax = vmax;
|
||||
ret->uorder = uorder;
|
||||
ret->vorder = vorder;
|
||||
ret->dimension = dimension;
|
||||
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
|
||||
assert(ret->ctlpoints);
|
||||
|
||||
/*copy the control points there*/
|
||||
int the_ustride = vorder * dimension;
|
||||
int the_vstride = dimension;
|
||||
for(int i=0; i<uorder; i++)
|
||||
for(int j=0; j<vorder; j++)
|
||||
for(int k=0; k<dimension; k++)
|
||||
ret->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
|
||||
|
||||
ret->next = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*deallocate the space as allocated by Make
|
||||
*/
|
||||
void bezierPatchDelete(bezierPatch *b)
|
||||
{
|
||||
free(b->ctlpoints);
|
||||
free(b);
|
||||
}
|
||||
|
||||
/*delete the whole linked list
|
||||
*/
|
||||
void bezierPatchDeleteList(bezierPatch *b)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
while (b != NULL) {
|
||||
temp = b;
|
||||
b = b->next;
|
||||
bezierPatchDelete(temp);
|
||||
}
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b)
|
||||
{
|
||||
b->next = list;
|
||||
return b;
|
||||
}
|
||||
|
||||
/*print the data stored in this patch*/
|
||||
void bezierPatchPrint(bezierPatch *b)
|
||||
{
|
||||
printf("bezierPatch:\n");
|
||||
printf("umin,umax=(%f,%f), (vmin, vmax)=(%f,%f)\n", b->umin, b->umax, b->vmin, b->vmax);
|
||||
printf("uorder=%i, vorder=%i\n", b->uorder, b->vorder);
|
||||
printf("idmension = %i\n", b->dimension);
|
||||
}
|
||||
|
||||
/*print the whole list*/
|
||||
void bezierPatchPrintList(bezierPatch *list)
|
||||
{
|
||||
bezierPatch* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
bezierPatchPrint(temp);
|
||||
}
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[])
|
||||
{
|
||||
if( u >= b->umin && u<= b->umax
|
||||
&& v >= b->vmin && v<= b->vmax)
|
||||
{
|
||||
|
||||
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
}
|
||||
else if(b->next != NULL)
|
||||
bezierPatchEval(b->next, u,v, ret);
|
||||
else
|
||||
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
}
|
||||
|
||||
/*the returned normal is normlized
|
||||
*/
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[])
|
||||
{
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
if( u >= b->umin && u<= b->umax
|
||||
&& v >= b->vmin && v<= b->vmax)
|
||||
{
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
}
|
||||
else if(b->next != NULL)
|
||||
bezierPatchEvalNormal(b->next, u,v, ret);
|
||||
else
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
}
|
||||
|
||||
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso)
|
||||
{
|
||||
if(bpatch->dimension == 3)
|
||||
glMap2f(GL_MAP2_VERTEX_3, bpatch->umin, bpatch->umax, 3*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
|
||||
else
|
||||
glMap2f(GL_MAP2_VERTEX_4, bpatch->umin, bpatch->umax, 4*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
|
||||
|
||||
glMapGrid2f(u_reso, bpatch->umin, bpatch->umax,
|
||||
v_reso, bpatch->vmin, bpatch->vmax);
|
||||
glEvalMesh2(GL_LINE, 0, u_reso, 0, v_reso);
|
||||
}
|
||||
|
||||
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_MAP2_VERTEX_3);
|
||||
glEnable(GL_AUTO_NORMAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glColor3f(1,0,0);
|
||||
#ifdef DEBUG
|
||||
printf("mapmap\n");
|
||||
#endif
|
||||
|
||||
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
bezierPatchDraw(temp, u_reso, v_reso);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _BEZIERPATCH_H
|
||||
#define _BEZIERPATCH_H
|
||||
|
||||
typedef struct bezierPatch{
|
||||
float umin, vmin, umax, vmax;
|
||||
int uorder; /*order= degree + 1*/
|
||||
int vorder;
|
||||
|
||||
/*
|
||||
*the control points are stored in a one dimensional array.
|
||||
*the surface is defined as:
|
||||
* s(u,v) = sum_{i,j} P(i,j) * B_i(u) * B_j(v).
|
||||
*where P(i,j) are the control points, B_i(.) are Bezier
|
||||
*basis functions.
|
||||
*Each control point can have dimension 3 or 4: (x,y,z,w).
|
||||
*The components of P(i,j) are stored in a one dimensional
|
||||
*array:
|
||||
* ctlpoints[]
|
||||
*in the order of:
|
||||
* P[0,0], P[0,1], ..., P[0,vorder-1],
|
||||
* P[1,0], P[1,1], ..., P[1,vorder-1],
|
||||
* ...
|
||||
* P[uorder-1,0], P[uorder-1,1], ..., P[uorder-1,vorder-1].
|
||||
*/
|
||||
int dimension;
|
||||
float* ctlpoints;
|
||||
|
||||
/*
|
||||
*in case we have to manage multiple bezierPatches.
|
||||
*/
|
||||
struct bezierPatch *next;
|
||||
|
||||
} bezierPatch;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension);
|
||||
|
||||
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension, int ustride, int vstride, float *ctlpoints);
|
||||
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b);
|
||||
|
||||
void bezierPatchDelete(bezierPatch *b);
|
||||
|
||||
void bezierPatchDeleteList(bezierPatch *b);
|
||||
|
||||
void bezierPatchPrint(bezierPatch *b);
|
||||
|
||||
void bezierPatchPrintList(bezierPatch *list);
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float retNormal[]);
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
|
||||
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso);
|
||||
|
||||
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -1,610 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <GL/gl.h>
|
||||
#include "bezierEval.h"
|
||||
#include "bezierPatchMesh.h"
|
||||
|
||||
static int isDegenerate(float A[2], float B[2], float C[2]);
|
||||
|
||||
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips)
|
||||
{
|
||||
int i,j,k;
|
||||
k=0;
|
||||
/*k is the index of the first component of the current vertex*/
|
||||
for(i=0; i<num_strips; i++)
|
||||
{
|
||||
glBegin(type_array[i]);
|
||||
for(j=0; j<length_array[i]; j++)
|
||||
{
|
||||
glNormal3fv(normal_array+k);
|
||||
glVertex3fv(vertex_array+k);
|
||||
k += 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDelDeg(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshDelDeg(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDelete(bezierPatchMesh *list)
|
||||
{
|
||||
if(list == NULL) return;
|
||||
bezierPatchMeshListDelete(list->next);
|
||||
bezierPatchMeshDelete(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* ret=NULL;
|
||||
bezierPatchMesh* temp;
|
||||
bezierPatchMesh* nextone;
|
||||
for(temp = list; temp != NULL; temp = nextone)
|
||||
{
|
||||
nextone = temp->next;
|
||||
ret=bezierPatchMeshListInsert(ret, temp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*maptype is either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4
|
||||
*/
|
||||
bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array)
|
||||
{
|
||||
int i,j,k;
|
||||
int dimension;
|
||||
int the_ustride;
|
||||
int the_vstride;
|
||||
|
||||
if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
|
||||
else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
|
||||
else {
|
||||
fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
|
||||
assert(ret);
|
||||
|
||||
ret->bpatch_normal = NULL;
|
||||
ret->bpatch_color = NULL;
|
||||
ret->bpatch_texcoord = NULL;
|
||||
ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
|
||||
|
||||
/*copy the control points there*/
|
||||
the_ustride = vorder * dimension;
|
||||
the_vstride = dimension;
|
||||
for(i=0; i<uorder; i++)
|
||||
for(j=0; j<vorder; j++)
|
||||
for(k=0; k<dimension; k++)
|
||||
ret->bpatch->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
|
||||
|
||||
|
||||
ret->size_UVarray = size_UVarray;
|
||||
ret->size_length_array = size_length_array;
|
||||
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
|
||||
assert(ret->UVarray);
|
||||
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
|
||||
assert(ret->length_array);
|
||||
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
|
||||
assert(ret->type_array);
|
||||
|
||||
ret->index_UVarray = 0;
|
||||
ret->index_length_array = 0;
|
||||
|
||||
ret->vertex_array = NULL;
|
||||
ret->normal_array = NULL;
|
||||
ret->color_array = NULL;
|
||||
ret->texcoord_array = NULL;
|
||||
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array)
|
||||
{
|
||||
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
|
||||
assert(ret);
|
||||
|
||||
ret->bpatch = NULL;
|
||||
ret->bpatch_normal = NULL;
|
||||
ret->bpatch_color = NULL;
|
||||
ret->bpatch_texcoord = NULL;
|
||||
|
||||
ret->size_UVarray = size_UVarray;
|
||||
ret->size_length_array = size_length_array;
|
||||
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
|
||||
assert(ret->UVarray);
|
||||
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
|
||||
assert(ret->length_array);
|
||||
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
|
||||
assert(ret->type_array);
|
||||
|
||||
ret->index_UVarray = 0;
|
||||
ret->index_length_array = 0;
|
||||
|
||||
ret->vertex_array = NULL;
|
||||
ret->normal_array = NULL;
|
||||
ret->color_array = NULL;
|
||||
ret->texcoord_array = NULL;
|
||||
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints)
|
||||
{
|
||||
switch(maptype){
|
||||
case GL_MAP2_VERTEX_3:
|
||||
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_VERTEX_4:
|
||||
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4,ustride, vstride, ctlpoints );
|
||||
break;
|
||||
case GL_MAP2_NORMAL:
|
||||
bpm->bpatch_normal = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_INDEX:
|
||||
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_COLOR_4:
|
||||
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_1:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_2:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 2, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_3:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_4:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error in bezierPatchMeshPutPatch, maptype=%i is wrong, maptype,map is invalid\n", maptype);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*delete everything including the arrays. So if you want to output the
|
||||
*pointers of the arrays, you should not use this function to deallocate space.
|
||||
*you should dealocate manually
|
||||
*/
|
||||
void bezierPatchMeshDelete(bezierPatchMesh *bpm)
|
||||
{
|
||||
if(bpm->bpatch != NULL)
|
||||
bezierPatchDelete(bpm->bpatch);
|
||||
if(bpm->bpatch_normal != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_normal);
|
||||
if(bpm->bpatch_color != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_color);
|
||||
if(bpm->bpatch_texcoord != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_texcoord);
|
||||
|
||||
free(bpm->UVarray);
|
||||
free(bpm->length_array);
|
||||
free(bpm->vertex_array);
|
||||
free(bpm->normal_array);
|
||||
free(bpm->type_array);
|
||||
free(bpm);
|
||||
}
|
||||
|
||||
/*begin a strip
|
||||
*type is the primitive type:
|
||||
*/
|
||||
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type)
|
||||
{
|
||||
bpm->counter = 0;
|
||||
bpm->type = type;
|
||||
}
|
||||
|
||||
/*signal the end of the current strip*/
|
||||
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm)
|
||||
{
|
||||
int i;
|
||||
|
||||
/*if there are no vertices in this strip, then nothing needs to be done*/
|
||||
if(bpm->counter == 0) return;
|
||||
|
||||
/*if the length_array is full, it should be expanded*/
|
||||
if(bpm->index_length_array >= bpm->size_length_array)
|
||||
{
|
||||
int *temp = (int*) malloc(sizeof(int) * (bpm->size_length_array*2 + 1));
|
||||
assert(temp);
|
||||
GLenum *temp_type = (GLenum*) malloc(sizeof(GLenum) * (bpm->size_length_array*2 + 1));
|
||||
assert(temp_type);
|
||||
/*update the size*/
|
||||
bpm->size_length_array = bpm->size_length_array*2 + 1;
|
||||
|
||||
/*copy*/
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
temp[i] = bpm->length_array[i];
|
||||
temp_type[i] = bpm->type_array[i];
|
||||
}
|
||||
|
||||
/*deallocate old array*/
|
||||
free(bpm->length_array);
|
||||
free(bpm->type_array);
|
||||
|
||||
/*point to the new array which is twice as bigger*/
|
||||
bpm->length_array = temp;
|
||||
bpm->type_array = temp_type;
|
||||
}
|
||||
bpm->type_array[bpm->index_length_array] = bpm->type;
|
||||
bpm->length_array[bpm->index_length_array++] = bpm->counter;
|
||||
|
||||
}
|
||||
|
||||
/*insert (u,v) */
|
||||
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v)
|
||||
{
|
||||
int i;
|
||||
/*if the UVarray is full, it should be expanded*/
|
||||
if(bpm->index_UVarray+1 >= bpm->size_UVarray)
|
||||
{
|
||||
float *temp = (float*) malloc(sizeof(float) * (bpm->size_UVarray * 2 + 2));
|
||||
assert(temp);
|
||||
|
||||
/*update the size*/
|
||||
bpm->size_UVarray = bpm->size_UVarray*2 + 2;
|
||||
|
||||
/*copy*/
|
||||
for(i=0; i<bpm->index_UVarray; i++)
|
||||
{
|
||||
temp[i] = bpm->UVarray[i];
|
||||
}
|
||||
|
||||
/*deallocate old array*/
|
||||
free(bpm->UVarray);
|
||||
|
||||
/*pointing to the new arrays*/
|
||||
bpm->UVarray = temp;
|
||||
}
|
||||
/*insert the new UV*/
|
||||
bpm->UVarray[bpm->index_UVarray] = u;
|
||||
bpm->index_UVarray++;
|
||||
bpm->UVarray[bpm->index_UVarray] = v;
|
||||
bpm->index_UVarray++;
|
||||
|
||||
/*update counter: one more vertex*/
|
||||
bpm->counter++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void bezierPatchMeshPrint(bezierPatchMesh *bpm)
|
||||
{
|
||||
int i;
|
||||
printf("the bezier patch is\n");
|
||||
bezierPatchPrint(bpm->bpatch);
|
||||
printf("index_length_array= %i\n", bpm->index_length_array);
|
||||
printf("size_length_array =%i\n", bpm->size_length_array);
|
||||
printf("index_UVarray =%i\n", bpm->index_UVarray);
|
||||
printf("size_UVarray =%i\n", bpm->size_UVarray);
|
||||
printf("UVarray is\n");
|
||||
for(i=0; i<bpm->index_UVarray; i++)
|
||||
printf("%f ", bpm->UVarray[i]);
|
||||
|
||||
printf("length_array is\n");
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
printf("%i ", bpm->length_array[i]);
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
/*insert a new patch in front of the current linked list and return the new list*/
|
||||
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm)
|
||||
{
|
||||
bpm->next=list;
|
||||
return bpm;
|
||||
}
|
||||
|
||||
/*print all the patches*/
|
||||
void bezierPatchMeshListPrint(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh *temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshPrint(temp);
|
||||
}
|
||||
}
|
||||
|
||||
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh *temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += temp->index_length_array;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int bezierPatchMeshListTotalVert(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh *temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += temp->index_UVarray;
|
||||
}
|
||||
return sum/2;
|
||||
}
|
||||
|
||||
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += bezierPatchMeshNumTriangles(temp);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i;
|
||||
int sum=0;
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
switch(bpm->type_array[i])
|
||||
{
|
||||
case GL_TRIANGLES:
|
||||
sum += bpm->length_array[i]/3;
|
||||
break;
|
||||
case GL_TRIANGLE_FAN:
|
||||
if(bpm->length_array[i] > 2)
|
||||
sum += bpm->length_array[i]-2;
|
||||
break;
|
||||
case GL_TRIANGLE_STRIP:
|
||||
if(bpm->length_array[i] > 2)
|
||||
sum += bpm->length_array[i]-2;
|
||||
break;
|
||||
case GL_QUAD_STRIP:
|
||||
if(bpm->length_array[i]>2)
|
||||
sum += (bpm->length_array[i]-2);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"error in bezierPatchMeshListNumTriangles, type invalid\n");
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*delete degenerate triangles*/
|
||||
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm)
|
||||
{
|
||||
if(bpm == NULL) return;
|
||||
int i,j,k;
|
||||
int *new_length_array;
|
||||
GLenum *new_type_array;
|
||||
int index_new_length_array;
|
||||
float *new_UVarray;
|
||||
int index_new_UVarray;
|
||||
|
||||
new_length_array = (int*)malloc(sizeof(int) * bpm->index_length_array);
|
||||
assert(new_length_array);
|
||||
new_type_array = (GLenum*)malloc(sizeof(GLenum) * bpm->index_length_array);
|
||||
assert(new_length_array);
|
||||
new_UVarray = (float*) malloc(sizeof(float) * bpm->index_UVarray);
|
||||
assert(new_UVarray);
|
||||
|
||||
index_new_length_array = 0;
|
||||
index_new_UVarray=0;
|
||||
k=0;
|
||||
for(i=0; i<bpm->index_length_array; i++){
|
||||
|
||||
/*(if not degenerate, we have to copy*/
|
||||
if( (bpm->length_array[i] != 3) || (!isDegenerate(bpm->UVarray+k, bpm->UVarray+k+2, bpm->UVarray+k+4)))
|
||||
{
|
||||
for(j=0; j<2* bpm->length_array[i]; j++)
|
||||
new_UVarray[index_new_UVarray++] = bpm->UVarray[k++];
|
||||
|
||||
new_length_array[index_new_length_array] = bpm->length_array[i];
|
||||
new_type_array[index_new_length_array] = bpm->type_array[i];
|
||||
index_new_length_array++;
|
||||
}
|
||||
else
|
||||
{
|
||||
k += 6;
|
||||
}
|
||||
}
|
||||
free(bpm->UVarray);
|
||||
free(bpm->length_array);
|
||||
free(bpm->type_array);
|
||||
bpm->UVarray=new_UVarray;
|
||||
bpm->length_array=new_length_array;
|
||||
bpm->type_array=new_type_array;
|
||||
bpm->index_UVarray = index_new_UVarray;
|
||||
bpm->index_length_array = index_new_length_array;
|
||||
|
||||
}
|
||||
|
||||
/*(u,v) to XYZ
|
||||
*the xyz and normals are stored in vertex_array,
|
||||
*and normal_array. the spaces of both are allocated here
|
||||
*/
|
||||
void bezierPatchMeshEval(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i,j,k,l;
|
||||
float u,v;
|
||||
float u0 = bpm->bpatch->umin;
|
||||
float u1 = bpm->bpatch->umax;
|
||||
int uorder = bpm->bpatch->uorder;
|
||||
float v0 = bpm->bpatch->vmin;
|
||||
float v1 = bpm->bpatch->vmax;
|
||||
int vorder = bpm->bpatch->vorder;
|
||||
int dimension = bpm->bpatch->dimension;
|
||||
int ustride = dimension * vorder;
|
||||
int vstride = dimension;
|
||||
float *ctlpoints = bpm->bpatch->ctlpoints;
|
||||
|
||||
bpm->vertex_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
|
||||
assert(bpm->vertex_array);
|
||||
bpm->normal_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
|
||||
assert(bpm->normal_array);
|
||||
|
||||
k=0;
|
||||
l=0;
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
for(j=0; j<bpm->length_array[i]; j++)
|
||||
{
|
||||
u = bpm->UVarray[k];
|
||||
v = bpm->UVarray[k+1];
|
||||
bezierSurfEval(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->vertex_array+l);
|
||||
bezierSurfEvalNormal(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->normal_array+l);
|
||||
k += 2;
|
||||
l += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListEval(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshEval(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshDraw(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i,j,k;
|
||||
k=0;
|
||||
/*k is the index of the first component of the current vertex*/
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
glBegin(bpm->type_array[i]);
|
||||
for(j=0; j<bpm->length_array[i]; j++)
|
||||
{
|
||||
glNormal3fv(bpm->normal_array+k);
|
||||
glVertex3fv(bpm->vertex_array+k);
|
||||
k+= 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDraw(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshDraw(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips)
|
||||
{
|
||||
int i,j,k,l;
|
||||
bezierPatchMesh *temp;
|
||||
int total_num_vertices = bezierPatchMeshListTotalVert(list);
|
||||
(*vertex_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
|
||||
assert(*vertex_array);
|
||||
(*normal_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
|
||||
assert(*normal_array);
|
||||
|
||||
*num_strips = bezierPatchMeshListTotalStrips(list);
|
||||
|
||||
*length_array = (int*) malloc(sizeof(int) * (*num_strips));
|
||||
assert(*length_array);
|
||||
|
||||
*type_array = (GLenum*) malloc(sizeof(GLenum) * (*num_strips));
|
||||
assert(*type_array);
|
||||
|
||||
k=0;
|
||||
l=0;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
int x=0;
|
||||
for(i=0; i<temp->index_length_array; i++)
|
||||
{
|
||||
for(j=0; j<temp->length_array[i]; j++)
|
||||
{
|
||||
(*vertex_array)[k] = temp->vertex_array[x];
|
||||
(*vertex_array)[k+1] = temp->vertex_array[x+1];
|
||||
(*vertex_array)[k+2] = temp->vertex_array[x+2];
|
||||
|
||||
(*normal_array)[k] = temp->normal_array[x];
|
||||
(*normal_array)[k+1] = temp->normal_array[x+1];
|
||||
(*normal_array)[k+2] = temp->normal_array[x+2];
|
||||
|
||||
x += 3;
|
||||
k += 3;
|
||||
}
|
||||
(*type_array)[l] = temp->type_array[i];
|
||||
(*length_array)[l++] = temp->length_array[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int isDegenerate(float A[2], float B[2], float C[2])
|
||||
{
|
||||
if( (A[0] == B[0] && A[1]==B[1]) ||
|
||||
(A[0] == C[0] && A[1]==C[1]) ||
|
||||
(B[0] == C[0] && B[1]==C[1])
|
||||
)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _BEZIERPATCHMESH_H
|
||||
#define _BEZIERPATCHMESH_H
|
||||
|
||||
#include "bezierPatch.h"
|
||||
|
||||
typedef struct bezierPatchMesh{
|
||||
bezierPatch *bpatch; /*vertex*/
|
||||
bezierPatch *bpatch_normal;
|
||||
bezierPatch *bpatch_texcoord; /*s,t,r,q*/
|
||||
bezierPatch *bpatch_color; /*RGBA*/
|
||||
|
||||
float *UVarray; /*all UV components of all vertices of all strips*/
|
||||
int *length_array; /*[i] is the number of vertices in the ith strip*/
|
||||
GLenum *type_array; /*[i] is the type of the ith primitive*/
|
||||
|
||||
/*to support dynamic insertion*/
|
||||
int size_UVarray;
|
||||
int index_UVarray;
|
||||
int size_length_array;
|
||||
int index_length_array;
|
||||
|
||||
int counter; /*track the current strip size*/
|
||||
GLenum type; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
|
||||
|
||||
/*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
|
||||
float *vertex_array; /*each vertex contains three components*/
|
||||
float *normal_array; /*each normal contains three components*/
|
||||
float *color_array;
|
||||
float *texcoord_array;
|
||||
|
||||
/*in case we need a linked list*/
|
||||
struct bezierPatchMesh *next;
|
||||
} bezierPatchMesh;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array);
|
||||
|
||||
/*initilize patches to be null*/
|
||||
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array);
|
||||
|
||||
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints);
|
||||
|
||||
void bezierPatchMeshDelete(bezierPatchMesh *bpm);
|
||||
|
||||
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type);
|
||||
|
||||
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm);
|
||||
|
||||
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v);
|
||||
|
||||
void bezierPatchMeshPrint(bezierPatchMesh *bpm);
|
||||
|
||||
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm);
|
||||
|
||||
void bezierPatchMeshListPrint(bezierPatchMesh* list);
|
||||
|
||||
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list);
|
||||
|
||||
int bezierPatchMeshListTotalVert(bezierPatchMesh* list);
|
||||
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm);
|
||||
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list);
|
||||
|
||||
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm);
|
||||
|
||||
|
||||
void bezierPatchMeshEval(bezierPatchMesh* bpm);
|
||||
|
||||
void bezierPatchMeshDraw(bezierPatchMesh* bpm);
|
||||
|
||||
void bezierPatchMeshListDraw(bezierPatchMesh* list);
|
||||
void bezierPatchMeshListEval(bezierPatchMesh* list);
|
||||
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips);
|
||||
|
||||
void bezierPatchMeshListDelDeg(bezierPatchMesh* list);
|
||||
void bezierPatchMeshListDelete(bezierPatchMesh *list);
|
||||
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list);
|
||||
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,402 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glcurveval.c++
|
||||
*
|
||||
*/
|
||||
|
||||
/* Polynomial Evaluator Interface */
|
||||
|
||||
#include "gluos.h"
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
#include "glcurveval.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
OpenGLCurveEvaluator::OpenGLCurveEvaluator(void)
|
||||
{
|
||||
//no default callback functions
|
||||
beginCallBackN = NULL;
|
||||
endCallBackN = NULL;
|
||||
vertexCallBackN = NULL;
|
||||
normalCallBackN = NULL;
|
||||
colorCallBackN = NULL;
|
||||
texcoordCallBackN = NULL;
|
||||
beginCallBackData = NULL;
|
||||
endCallBackData = NULL;
|
||||
vertexCallBackData = NULL;
|
||||
normalCallBackData = NULL;
|
||||
colorCallBackData = NULL;
|
||||
texcoordCallBackData = NULL;
|
||||
|
||||
userData = NULL;
|
||||
|
||||
vertex_flag = 0;
|
||||
normal_flag = 0;
|
||||
color_flag = 0;
|
||||
texcoord_flag = 0;
|
||||
|
||||
em_vertex.uprime = -1.0;
|
||||
em_normal.uprime = -1.0;
|
||||
em_color.uprime = -1.0;
|
||||
em_texcoord.uprime = -1.0;
|
||||
output_triangles = 0; // don't output triangles by default
|
||||
}
|
||||
|
||||
OpenGLCurveEvaluator::~OpenGLCurveEvaluator(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* added nonsense to avoid the warning messages at compile time */
|
||||
void
|
||||
OpenGLCurveEvaluator::addMap(CurveMap *m)
|
||||
{
|
||||
m = m;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::range1f(long type, REAL *from, REAL *to)
|
||||
{
|
||||
type = type;
|
||||
from = from;
|
||||
to = to;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::domain1f(REAL ulo, REAL uhi)
|
||||
{
|
||||
ulo = ulo;
|
||||
uhi = uhi;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::bgnline(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
beginCallBack(GL_LINE_STRIP, userData);
|
||||
else
|
||||
glBegin((GLenum) GL_LINE_STRIP);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::endline(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
endCallBack(userData);
|
||||
else
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* disable - turn off a curve map
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::disable(long type)
|
||||
{
|
||||
glDisable((GLenum) type);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* enable - turn on a curve map
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::enable(long type)
|
||||
{
|
||||
glEnable((GLenum) type);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* mapgrid1f - define a lattice of points with origin and offset
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::mapgrid1f(long nu, REAL u0, REAL u1)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
global_grid_u0 = u0;
|
||||
global_grid_u1 = u1;
|
||||
global_grid_nu = (int) nu;
|
||||
}
|
||||
else
|
||||
glMapGrid1f((GLint) nu, (GLfloat) u0, (GLfloat) u1);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnmap1 - preamble to curve definition and evaluations
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::bgnmap1f(long)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
//initialized so that no maps are set initially
|
||||
vertex_flag = 0;
|
||||
normal_flag = 0;
|
||||
color_flag = 0;
|
||||
texcoord_flag = 0;
|
||||
//no need to worry about gl states when doing callback
|
||||
}
|
||||
else
|
||||
glPushAttrib((GLbitfield) GL_EVAL_BIT);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endmap1 - postamble to a curve map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::endmap1f(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* map1f - pass a desription of a curve map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::map1f(
|
||||
long type, /* map type */
|
||||
REAL ulo, /* lower parametric bound */
|
||||
REAL uhi, /* upper parametric bound */
|
||||
long stride, /* distance to next point in REALS */
|
||||
long order, /* parametric order */
|
||||
REAL *pts /* control points */
|
||||
)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
int dimension = 0;
|
||||
int which = 0;
|
||||
switch(type){
|
||||
case GL_MAP1_VERTEX_3:
|
||||
which = 0;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_VERTEX_4:
|
||||
which=0;
|
||||
dimension = 4;
|
||||
break;
|
||||
case GL_MAP1_INDEX:
|
||||
which=2;
|
||||
dimension = 1;
|
||||
break;
|
||||
case GL_MAP1_COLOR_4:
|
||||
which=2;
|
||||
dimension = 4;
|
||||
break;
|
||||
case GL_MAP1_NORMAL:
|
||||
which=1;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_1:
|
||||
which=3;
|
||||
dimension = 1;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_2:
|
||||
which=3;
|
||||
dimension = 2;
|
||||
break;
|
||||
|
||||
case GL_MAP1_TEXTURE_COORD_3:
|
||||
which=3;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_4:
|
||||
which=3;
|
||||
dimension = 4;
|
||||
break;
|
||||
}
|
||||
inMap1f(which, dimension, ulo, uhi, stride, order, pts);
|
||||
}
|
||||
else
|
||||
glMap1f((GLenum) type, (GLfloat) ulo, (GLfloat) uhi, (GLint) stride,
|
||||
(GLint) order, (const GLfloat *) pts);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* mapmesh1f - evaluate a mesh of points on lattice
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::mapmesh1f(long style, long from, long to)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
inMapMesh1f((int) from, (int) to);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(style) {
|
||||
default:
|
||||
case N_MESHFILL:
|
||||
case N_MESHLINE:
|
||||
glEvalMesh1((GLenum) GL_LINE, (GLint) from, (GLint) to);
|
||||
break;
|
||||
case N_MESHPOINT:
|
||||
glEvalMesh1((GLenum) GL_POINT, (GLint) from, (GLint) to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* evalpoint1i - evaluate a point on a curve
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::evalpoint1i(long i)
|
||||
{
|
||||
glEvalPoint1((GLint) i);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* evalcoord1f - evaluate a point on a curve
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::evalcoord1f(long, REAL u)
|
||||
{
|
||||
glEvalCoord1f((GLfloat) u);
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef _WIN32
|
||||
OpenGLCurveEvaluator::putCallBack(GLenum which, void (GLAPIENTRY *fn)())
|
||||
#else
|
||||
OpenGLCurveEvaluator::putCallBack(GLenum which, _GLUfuncptr fn)
|
||||
#endif
|
||||
{
|
||||
switch(which)
|
||||
{
|
||||
case GLU_NURBS_BEGIN:
|
||||
beginCallBackN = (void (GLAPIENTRY *) (GLenum)) fn;
|
||||
break;
|
||||
case GLU_NURBS_END:
|
||||
endCallBackN = (void (GLAPIENTRY *) (void)) fn;
|
||||
break;
|
||||
case GLU_NURBS_VERTEX:
|
||||
vertexCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_NORMAL:
|
||||
normalCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_COLOR:
|
||||
colorCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_TEXTURE_COORD:
|
||||
texcoordCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_BEGIN_DATA:
|
||||
beginCallBackData = (void (GLAPIENTRY *) (GLenum, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_END_DATA:
|
||||
endCallBackData = (void (GLAPIENTRY *) (void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_VERTEX_DATA:
|
||||
vertexCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_NORMAL_DATA:
|
||||
normalCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_COLOR_DATA:
|
||||
colorCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_TEXTURE_COORD_DATA:
|
||||
texcoordCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::beginCallBack(GLenum which, void *data)
|
||||
{
|
||||
if(beginCallBackData)
|
||||
beginCallBackData(which, data);
|
||||
else if(beginCallBackN)
|
||||
beginCallBackN(which);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::endCallBack(void *data)
|
||||
{
|
||||
if(endCallBackData)
|
||||
endCallBackData(data);
|
||||
else if(endCallBackN)
|
||||
endCallBackN();
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::vertexCallBack(const GLfloat *vert, void* data)
|
||||
{
|
||||
if(vertexCallBackData)
|
||||
vertexCallBackData(vert, data);
|
||||
else if(vertexCallBackN)
|
||||
vertexCallBackN(vert);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::normalCallBack(const GLfloat *normal, void* data)
|
||||
{
|
||||
if(normalCallBackData)
|
||||
normalCallBackData(normal, data);
|
||||
else if(normalCallBackN)
|
||||
normalCallBackN(normal);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::colorCallBack(const GLfloat *color, void* data)
|
||||
{
|
||||
if(colorCallBackData)
|
||||
colorCallBackData(color, data);
|
||||
else if(colorCallBackN)
|
||||
colorCallBackN(color);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::texcoordCallBack(const GLfloat *texcoord, void* data)
|
||||
{
|
||||
if(texcoordCallBackData)
|
||||
texcoordCallBackData(texcoord, data);
|
||||
else if(texcoordCallBackN)
|
||||
texcoordCallBackN(texcoord);
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glcurveval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluglcurveval_h_
|
||||
#define __gluglcurveval_h_
|
||||
|
||||
#include "gluos.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "basiccrveval.h"
|
||||
|
||||
class CurveMap;
|
||||
|
||||
/*for internal evaluator callback stuff*/
|
||||
#ifndef IN_MAX_BEZIER_ORDER
|
||||
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
|
||||
#endif
|
||||
|
||||
#ifndef IN_MAX_DIMENSION
|
||||
#define IN_MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
typedef struct curveEvalMachine{
|
||||
REAL uprime; //cached previously evaluated uprime
|
||||
int k; //the dimension
|
||||
REAL u1;
|
||||
REAL u2;
|
||||
int ustride;
|
||||
int uorder;
|
||||
REAL ctlpoints[IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
REAL ucoeff[IN_MAX_BEZIER_ORDER];//cache the polynomial values
|
||||
} curveEvalMachine;
|
||||
|
||||
class OpenGLCurveEvaluator : public BasicCurveEvaluator {
|
||||
public:
|
||||
OpenGLCurveEvaluator(void);
|
||||
virtual ~OpenGLCurveEvaluator(void);
|
||||
void range1f(long, REAL *, REAL *);
|
||||
void domain1f(REAL, REAL);
|
||||
void addMap(CurveMap *);
|
||||
|
||||
void enable(long);
|
||||
void disable(long);
|
||||
void bgnmap1f(long);
|
||||
void map1f(long, REAL, REAL, long, long, REAL *);
|
||||
void mapgrid1f(long, REAL, REAL);
|
||||
void mapmesh1f(long, long, long);
|
||||
void evalpoint1i(long);
|
||||
void evalcoord1f(long, REAL);
|
||||
void endmap1f(void);
|
||||
|
||||
void bgnline(void);
|
||||
void endline(void);
|
||||
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
output_triangles = flag;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
void putCallBack(GLenum which, void (GLAPIENTRY *fn)() );
|
||||
#else
|
||||
void putCallBack(GLenum which, _GLUfuncptr fn );
|
||||
#endif
|
||||
void set_callback_userData(void *data)
|
||||
{
|
||||
userData = data;
|
||||
}
|
||||
|
||||
/*------------------begin for curveEvalMachine------------*/
|
||||
curveEvalMachine em_vertex;
|
||||
curveEvalMachine em_normal;
|
||||
curveEvalMachine em_color;
|
||||
curveEvalMachine em_texcoord;
|
||||
int vertex_flag; //whether there is a vertex map or not
|
||||
int normal_flag; //whether there is a normal map or not
|
||||
int color_flag; //whether there is a color map or not
|
||||
int texcoord_flag; //whether there is a texture map or not
|
||||
|
||||
REAL global_grid_u0;
|
||||
REAL global_grid_u1;
|
||||
int global_grid_nu;
|
||||
|
||||
void inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
|
||||
int dimension,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL *ctlpoints);
|
||||
|
||||
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
|
||||
void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint);
|
||||
void inDoEvalCoord1(REAL u);
|
||||
void inMapMesh1f(int umin, int umax);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackN) (GLenum type);
|
||||
void (GLAPIENTRY *endCallBackN) (void);
|
||||
void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
|
||||
void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
|
||||
void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
|
||||
void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
|
||||
void (GLAPIENTRY *endCallBackData) (void* data);
|
||||
void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
|
||||
void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
|
||||
void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
|
||||
void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
|
||||
|
||||
void* userData; //the opaque pointer for Data callback functions
|
||||
void beginCallBack(GLenum type, void* data);
|
||||
void endCallBack(void* data);
|
||||
void vertexCallBack(const GLfloat *vert, void *data);
|
||||
void normalCallBack(const GLfloat *normal, void* data);
|
||||
void colorCallBack(const GLfloat *color, void* data);
|
||||
void texcoordCallBack(const GLfloat *texcoord, void* data);
|
||||
|
||||
|
||||
/*------------------end for curveEvalMachine------------*/
|
||||
|
||||
private:
|
||||
int output_triangles; //true 1; false 0
|
||||
};
|
||||
|
||||
#endif /* __gluglcurveval_h_ */
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glimports.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluimports_h_
|
||||
#define __gluimports_h_
|
||||
|
||||
#include "mystdlib.h"
|
||||
#include "mystdio.h"
|
||||
|
||||
#endif /* __gluimports_h_ */
|
|
@ -1,469 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
//#define DOWN_LOAD_NURBS
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
|
||||
#include "oglTrimNurbs.h"
|
||||
static int surfcount = 0;
|
||||
static oglTrimNurbs* otn = NULL;
|
||||
nurbSurf* tempNurb = NULL;
|
||||
oglTrimLoops* tempTrim = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
//for LOD
|
||||
extern "C" {void glu_LOD_eval_list(GLUnurbs *nurb, int level);}
|
||||
|
||||
void glu_LOD_eval_list(GLUnurbs *nurb, int level)
|
||||
{
|
||||
nurb->LOD_eval_list(level);
|
||||
}
|
||||
|
||||
GLUnurbs * GLAPIENTRY
|
||||
gluNewNurbsRenderer(void)
|
||||
{
|
||||
GLUnurbs *t;
|
||||
|
||||
t = new GLUnurbs();
|
||||
return t;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDeleteNurbsRenderer(GLUnurbs *r)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
|
||||
gluDeleteNurbsTessellatorEXT(GLUnurbsObj *r)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginSurface(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
surfcount++;
|
||||
tempTrim = OTL_make(10,10);
|
||||
#endif
|
||||
r->bgnsurface(0);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginCurve(GLUnurbs *r)
|
||||
{
|
||||
r->bgncurve(0);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndCurve(GLUnurbs *r)
|
||||
{
|
||||
r->endcurve();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndSurface(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
if(surfcount == 1)
|
||||
otn = OTN_make(1);
|
||||
OTN_insert(otn, tempNurb, tempTrim);
|
||||
if(surfcount >= 1)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("write file\n");
|
||||
#endif
|
||||
OTN_write(otn, "out.otn");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
r->endsurface();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginTrim(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_bgnTrim(tempTrim);
|
||||
#endif
|
||||
|
||||
r->bgntrim();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndTrim(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_endTrim(tempTrim);
|
||||
#endif
|
||||
r->endtrim();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPwlCurve(GLUnurbs *r, GLint count, INREAL array[],
|
||||
GLint stride, GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_pwlCurve(tempTrim, count, array, stride, type);
|
||||
#endif
|
||||
|
||||
int realType;
|
||||
switch(type) {
|
||||
case GLU_MAP1_TRIM_2:
|
||||
realType = N_P2D;
|
||||
break;
|
||||
case GLU_MAP1_TRIM_3:
|
||||
realType = N_P2DR;
|
||||
break;
|
||||
default:
|
||||
realType = type;
|
||||
break;
|
||||
}
|
||||
r->pwlcurve(count, array, sizeof(INREAL) * stride, realType);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsCurve(GLUnurbs *r, GLint nknots, INREAL knot[], GLint stride,
|
||||
INREAL ctlarray[], GLint order, GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_nurbsCurve(tempTrim, nknots, knot, stride, ctlarray, order, type);
|
||||
#endif
|
||||
|
||||
int realType;
|
||||
|
||||
switch(type) {
|
||||
case GLU_MAP1_TRIM_2:
|
||||
realType = N_P2D;
|
||||
break;
|
||||
case GLU_MAP1_TRIM_3:
|
||||
realType = N_P2DR;
|
||||
break;
|
||||
default:
|
||||
realType = type;
|
||||
break;
|
||||
}
|
||||
|
||||
r->nurbscurve(nknots, knot, sizeof(INREAL) * stride, ctlarray, order,
|
||||
realType);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsSurface(GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
|
||||
GLint tknot_count, GLfloat *tknot,
|
||||
GLint s_stride, GLint t_stride,
|
||||
GLfloat *ctlarray, GLint sorder, GLint torder,
|
||||
GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
{
|
||||
int dimension;
|
||||
switch(type){
|
||||
case GL_MAP2_VERTEX_3:
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP2_VERTEX_4:
|
||||
dimension = 4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error in glinterface.c++, type no implemented\n");
|
||||
exit(1);
|
||||
}
|
||||
tempNurb = nurbSurfMake(sknot_count, sknot,
|
||||
tknot_count, tknot,
|
||||
sorder, torder,
|
||||
dimension,
|
||||
ctlarray,
|
||||
s_stride, t_stride);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
|
||||
sizeof(INREAL) * s_stride, sizeof(INREAL) * t_stride,
|
||||
ctlarray, sorder, torder, type);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluLoadSamplingMatrices(GLUnurbs *r, const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
r->useGLMatrices(modelMatrix, projMatrix, viewport);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsProperty(GLUnurbs *r, GLenum property, GLfloat value)
|
||||
{
|
||||
GLfloat nurbsValue;
|
||||
|
||||
switch (property) {
|
||||
case GLU_AUTO_LOAD_MATRIX:
|
||||
r->setautoloadmode(value);
|
||||
return;
|
||||
|
||||
case GLU_CULLING:
|
||||
if (value != 0.0) {
|
||||
nurbsValue = N_CULLINGON;
|
||||
} else {
|
||||
nurbsValue = N_NOCULLING;
|
||||
}
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
|
||||
return;
|
||||
|
||||
case GLU_SAMPLING_METHOD:
|
||||
if (value == GLU_PATH_LENGTH) {
|
||||
nurbsValue = N_PATHLENGTH;
|
||||
} else if (value == GLU_PARAMETRIC_ERROR) {
|
||||
nurbsValue = N_PARAMETRICDISTANCE;
|
||||
} else if (value == GLU_DOMAIN_DISTANCE) {
|
||||
nurbsValue = N_DOMAINDISTANCE;
|
||||
r->set_is_domain_distance_sampling(1); //optimzing untrimmed case
|
||||
|
||||
} else if (value == GLU_OBJECT_PARAMETRIC_ERROR) {
|
||||
nurbsValue = N_OBJECTSPACE_PARA;
|
||||
r->setautoloadmode( 0.0 );
|
||||
r->setSamplingMatrixIdentity();
|
||||
} else if (value == GLU_OBJECT_PATH_LENGTH) {
|
||||
nurbsValue = N_OBJECTSPACE_PATH;
|
||||
r->setautoloadmode( 0.0 );
|
||||
r->setSamplingMatrixIdentity();
|
||||
} else {
|
||||
r->postError(GLU_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
|
||||
return;
|
||||
|
||||
case GLU_SAMPLING_TOLERANCE:
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
|
||||
return;
|
||||
|
||||
case GLU_PARAMETRIC_TOLERANCE:
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
|
||||
return;
|
||||
|
||||
|
||||
case GLU_DISPLAY_MODE:
|
||||
|
||||
if (value == GLU_FILL) {
|
||||
nurbsValue = N_FILL;
|
||||
} else if (value == GLU_OUTLINE_POLYGON) {
|
||||
nurbsValue = N_OUTLINE_POLY;
|
||||
} else if (value == GLU_OUTLINE_PATCH) {
|
||||
nurbsValue = N_OUTLINE_PATCH;
|
||||
} else {
|
||||
r->postError(GLU_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
r->setnurbsproperty(N_DISPLAY, nurbsValue);
|
||||
|
||||
break;
|
||||
|
||||
case GLU_U_STEP:
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
r->set_domain_distance_u_rate(value);
|
||||
break;
|
||||
|
||||
case GLU_V_STEP:
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
r->set_domain_distance_v_rate(value);
|
||||
break;
|
||||
|
||||
case GLU_NURBS_MODE:
|
||||
if(value == GLU_NURBS_RENDERER)
|
||||
r->put_callbackFlag(0);
|
||||
else if(value == GLU_NURBS_TESSELLATOR)
|
||||
r->put_callbackFlag(1);
|
||||
else
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluGetNurbsProperty(GLUnurbs *r, GLenum property, GLfloat *value)
|
||||
{
|
||||
GLfloat nurbsValue;
|
||||
|
||||
switch(property) {
|
||||
case GLU_AUTO_LOAD_MATRIX:
|
||||
if (r->getautoloadmode()) {
|
||||
*value = GL_TRUE;
|
||||
} else {
|
||||
*value = GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case GLU_CULLING:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
|
||||
if (nurbsValue == N_CULLINGON) {
|
||||
*value = GL_TRUE;
|
||||
} else {
|
||||
*value = GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case GLU_SAMPLING_METHOD:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
|
||||
if(*value == N_PATHLENGTH)
|
||||
*value = GLU_PATH_LENGTH;
|
||||
else if(*value == N_PARAMETRICDISTANCE)
|
||||
*value = GLU_PARAMETRIC_ERROR;
|
||||
else if(*value == N_DOMAINDISTANCE)
|
||||
*value = GLU_DOMAIN_DISTANCE;
|
||||
else if(*value == N_OBJECTSPACE_PATH)
|
||||
*value = GLU_OBJECT_PATH_LENGTH;
|
||||
else if(*value == N_OBJECTSPACE_PARA)
|
||||
*value = GLU_OBJECT_PARAMETRIC_ERROR;
|
||||
break;
|
||||
case GLU_SAMPLING_TOLERANCE:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
break;
|
||||
case GLU_PARAMETRIC_TOLERANCE:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
break;
|
||||
|
||||
case GLU_U_STEP:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
|
||||
break;
|
||||
case GLU_V_STEP:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
|
||||
break;
|
||||
case GLU_DISPLAY_MODE:
|
||||
r->getnurbsproperty(N_DISPLAY, &nurbsValue);
|
||||
if (nurbsValue == N_FILL) {
|
||||
*value = GLU_FILL;
|
||||
} else if (nurbsValue == N_OUTLINE_POLY) {
|
||||
*value = GLU_OUTLINE_POLYGON;
|
||||
} else {
|
||||
*value = GLU_OUTLINE_PATCH;
|
||||
}
|
||||
break;
|
||||
|
||||
case GLU_NURBS_MODE:
|
||||
if(r->is_callback())
|
||||
*value = GLU_NURBS_TESSELLATOR;
|
||||
else
|
||||
*value = GLU_NURBS_RENDERER;
|
||||
break;
|
||||
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void GLAPIENTRY
|
||||
gluNurbsCallback(GLUnurbs *r, GLenum which, _GLUfuncptr fn )
|
||||
{
|
||||
switch (which) {
|
||||
case GLU_NURBS_BEGIN:
|
||||
case GLU_NURBS_END:
|
||||
case GLU_NURBS_VERTEX:
|
||||
case GLU_NURBS_NORMAL:
|
||||
case GLU_NURBS_TEXTURE_COORD:
|
||||
case GLU_NURBS_COLOR:
|
||||
case GLU_NURBS_BEGIN_DATA:
|
||||
case GLU_NURBS_END_DATA:
|
||||
case GLU_NURBS_VERTEX_DATA:
|
||||
case GLU_NURBS_NORMAL_DATA:
|
||||
case GLU_NURBS_TEXTURE_COORD_DATA:
|
||||
case GLU_NURBS_COLOR_DATA:
|
||||
r->putSurfCallBack(which, fn);
|
||||
break;
|
||||
|
||||
case GLU_NURBS_ERROR:
|
||||
r->errorCallback = (void (APIENTRY *)( GLenum e )) fn;
|
||||
break;
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallbackDataEXT(GLUnurbs* r, void* userData)
|
||||
{
|
||||
r->setNurbsCallbackData(userData);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallbackData(GLUnurbs* r, void* userData)
|
||||
{
|
||||
gluNurbsCallbackDataEXT(r,userData);
|
||||
}
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
|
||||
GLUnurbs::GLUnurbs()
|
||||
: NurbsTessellator(curveEvaluator, surfaceEvaluator)
|
||||
{
|
||||
redefineMaps();
|
||||
defineMap(GL_MAP2_NORMAL, 0, 3);
|
||||
defineMap(GL_MAP1_NORMAL, 0, 3);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_1, 0, 1);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_1, 0, 1);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_2, 0, 2);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_2, 0, 2);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_3, 0, 3);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_3, 0, 3);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_4, 1, 4);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_4, 1, 4);
|
||||
defineMap(GL_MAP2_VERTEX_4, 1, 4);
|
||||
defineMap(GL_MAP1_VERTEX_4, 1, 4);
|
||||
defineMap(GL_MAP2_VERTEX_3, 0, 3);
|
||||
defineMap(GL_MAP1_VERTEX_3, 0, 3);
|
||||
defineMap(GL_MAP2_COLOR_4, 0, 4);
|
||||
defineMap(GL_MAP1_COLOR_4, 0, 4);
|
||||
defineMap(GL_MAP2_INDEX, 0, 1);
|
||||
defineMap(GL_MAP1_INDEX, 0, 1);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, (float) 100.0);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
set_domain_distance_u_rate(100.0);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, (float) 100.0);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
set_domain_distance_v_rate(100.0);
|
||||
set_is_domain_distance_sampling(0); //since the default is path_length
|
||||
|
||||
//default autoloadmode is true
|
||||
autoloadmode = 1;
|
||||
|
||||
//default callbackFlag is 0
|
||||
callbackFlag = 0;
|
||||
|
||||
errorCallback = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::bgnrender(void)
|
||||
{
|
||||
if (autoloadmode) {
|
||||
loadGLMatrices();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::endrender(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::errorHandler(int i)
|
||||
{
|
||||
int gluError;
|
||||
|
||||
gluError = i + (GLU_NURBS_ERROR1 - 1);
|
||||
postError( gluError );
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::loadGLMatrices(void)
|
||||
{
|
||||
GLfloat vmat[4][4];
|
||||
GLint viewport[4];
|
||||
|
||||
grabGLMatrix((GLfloat (*)[4]) vmat);
|
||||
loadCullingMatrix((GLfloat (*)[4]) vmat);
|
||||
::glGetIntegerv((GLenum) GL_VIEWPORT, (GLint *) viewport);
|
||||
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
GLfloat vmat[4][4];
|
||||
|
||||
multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix,
|
||||
(const GLfloat (*)[4]) projMatrix);
|
||||
loadCullingMatrix((GLfloat (*)[4]) vmat);
|
||||
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* grabGLMatrix
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
GLUnurbs::grabGLMatrix(GLfloat vmat[4][4])
|
||||
{
|
||||
GLfloat m1[4][4], m2[4][4];
|
||||
|
||||
::glGetFloatv((GLenum) GL_MODELVIEW_MATRIX, (GLfloat *) &(m1[0][0]));
|
||||
::glGetFloatv((GLenum) GL_PROJECTION_MATRIX, (GLfloat *) &(m2[0][0]));
|
||||
multmatrix4d((GLfloat (*)[4]) vmat,
|
||||
(const GLfloat (*)[4]) m1, (const GLfloat (*)[4]) m2);
|
||||
}
|
||||
|
||||
//for object space tesselation: view independent
|
||||
void
|
||||
GLUnurbs::setSamplingMatrixIdentity( void )
|
||||
{
|
||||
INREAL smat[4][4] = {
|
||||
{1,0,0,0},
|
||||
{0,1,0,0},
|
||||
{0,0,1,0},
|
||||
{0,0,0,1}
|
||||
};
|
||||
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
|
||||
/* rescale the mapping to correspond to pixels in x/y */
|
||||
REAL xsize = 0.5 * (REAL) (viewport[2]);
|
||||
REAL ysize = 0.5 * (REAL) (viewport[3]);
|
||||
|
||||
INREAL smat[4][4];
|
||||
smat[0][0] = vmat[0][0] * xsize;
|
||||
smat[1][0] = vmat[1][0] * xsize;
|
||||
smat[2][0] = vmat[2][0] * xsize;
|
||||
smat[3][0] = vmat[3][0] * xsize;
|
||||
|
||||
smat[0][1] = vmat[0][1] * ysize;
|
||||
smat[1][1] = vmat[1][1] * ysize;
|
||||
smat[2][1] = vmat[2][1] * ysize;
|
||||
smat[3][1] = vmat[3][1] * ysize;
|
||||
|
||||
smat[0][2] = 0.0;
|
||||
smat[1][2] = 0.0;
|
||||
smat[2][2] = 0.0;
|
||||
smat[3][2] = 0.0;
|
||||
|
||||
smat[0][3] = vmat[0][3];
|
||||
smat[1][3] = vmat[1][3];
|
||||
smat[2][3] = vmat[2][3];
|
||||
smat[3][3] = vmat[3][3];
|
||||
|
||||
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::loadCullingMatrix(GLfloat vmat[4][4])
|
||||
{
|
||||
INREAL cmat[4][4];
|
||||
|
||||
cmat[0][0] = vmat[0][0];
|
||||
cmat[0][1] = vmat[0][1];
|
||||
cmat[0][2] = vmat[0][2];
|
||||
cmat[0][3] = vmat[0][3];
|
||||
|
||||
cmat[1][0] = vmat[1][0];
|
||||
cmat[1][1] = vmat[1][1];
|
||||
cmat[1][2] = vmat[1][2];
|
||||
cmat[1][3] = vmat[1][3];
|
||||
|
||||
cmat[2][0] = vmat[2][0];
|
||||
cmat[2][1] = vmat[2][1];
|
||||
cmat[2][2] = vmat[2][2];
|
||||
cmat[2][3] = vmat[2][3];
|
||||
|
||||
cmat[3][0] = vmat[3][0];
|
||||
cmat[3][1] = vmat[3][1];
|
||||
cmat[3][2] = vmat[3][2];
|
||||
cmat[3][3] = vmat[3][3];
|
||||
|
||||
const long rstride = sizeof(cmat[0]) / sizeof(cmat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
//added for curves by zl
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* A = B * MAT ; transform a 4d vector through a 4x4 matrix
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
GLUnurbs::transform4d(GLfloat A[4], GLfloat B[4], GLfloat mat[4][4])
|
||||
{
|
||||
|
||||
A[0] = B[0]*mat[0][0] + B[1]*mat[1][0] + B[2]*mat[2][0] + B[3]*mat[3][0];
|
||||
A[1] = B[0]*mat[0][1] + B[1]*mat[1][1] + B[2]*mat[2][1] + B[3]*mat[3][1];
|
||||
A[2] = B[0]*mat[0][2] + B[1]*mat[1][2] + B[2]*mat[2][2] + B[3]*mat[3][2];
|
||||
A[3] = B[0]*mat[0][3] + B[1]*mat[1][3] + B[2]*mat[2][3] + B[3]*mat[3][3];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* new = [left][right] ; multiply two matrices together
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
GLUnurbs::multmatrix4d (GLfloat n[4][4], const GLfloat left[4][4],
|
||||
const GLfloat right[4][4])
|
||||
{
|
||||
transform4d ((GLfloat *) n[0],(GLfloat *) left[0],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[1],(GLfloat *) left[1],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[2],(GLfloat *) left[2],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[3],(GLfloat *) left[3],(GLfloat (*)[4]) right);
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glrenderer.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluglrenderer_h_
|
||||
#define __gluglrenderer_h_
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "nurbstess.h"
|
||||
#include "glsurfeval.h"
|
||||
#include "glcurveval.h"
|
||||
|
||||
extern "C" {
|
||||
typedef void (APIENTRY *errorCallbackType)( GLenum );
|
||||
}
|
||||
|
||||
class GLUnurbs : public NurbsTessellator {
|
||||
|
||||
public:
|
||||
GLUnurbs( void );
|
||||
void loadGLMatrices( void );
|
||||
void useGLMatrices( const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4] );
|
||||
void setSamplingMatrixIdentity( void );
|
||||
|
||||
void errorHandler( int );
|
||||
void bgnrender( void );
|
||||
void endrender( void );
|
||||
void setautoloadmode( INREAL value )
|
||||
{
|
||||
|
||||
if (value) autoloadmode = GL_TRUE;
|
||||
else autoloadmode = GL_FALSE;
|
||||
|
||||
}
|
||||
GLboolean getautoloadmode( void ) { return autoloadmode; }
|
||||
|
||||
errorCallbackType errorCallback;
|
||||
void postError( int which )
|
||||
{ if (errorCallback) (errorCallback)( (GLenum)which ); }
|
||||
#ifdef _WIN32
|
||||
void putSurfCallBack(GLenum which, void (GLAPIENTRY *fn)() )
|
||||
#else
|
||||
void putSurfCallBack(GLenum which, _GLUfuncptr fn )
|
||||
#endif
|
||||
{
|
||||
curveEvaluator.putCallBack(which, fn);
|
||||
surfaceEvaluator.putCallBack(which, fn);
|
||||
}
|
||||
|
||||
int get_vertices_call_back()
|
||||
{
|
||||
return surfaceEvaluator.get_vertices_call_back();
|
||||
}
|
||||
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
surfaceEvaluator.put_vertices_call_back(flag);
|
||||
}
|
||||
|
||||
int get_callback_auto_normal()
|
||||
{
|
||||
return surfaceEvaluator.get_callback_auto_normal();
|
||||
}
|
||||
|
||||
void put_callback_auto_normal(int flag)
|
||||
{
|
||||
surfaceEvaluator.put_callback_auto_normal(flag);
|
||||
}
|
||||
|
||||
void setNurbsCallbackData(void* userData)
|
||||
{
|
||||
curveEvaluator.set_callback_userData(userData);
|
||||
surfaceEvaluator.set_callback_userData(userData);
|
||||
}
|
||||
|
||||
|
||||
//for LOD
|
||||
void LOD_eval_list(int level)
|
||||
{
|
||||
surfaceEvaluator.LOD_eval_list(level);
|
||||
}
|
||||
|
||||
//NEWCALLBACK
|
||||
int is_callback()
|
||||
{
|
||||
return callbackFlag;
|
||||
}
|
||||
void put_callbackFlag(int flag)
|
||||
{
|
||||
callbackFlag = flag;
|
||||
surfaceEvaluator.put_vertices_call_back(flag);
|
||||
curveEvaluator.put_vertices_call_back(flag);
|
||||
}
|
||||
|
||||
private:
|
||||
GLboolean autoloadmode;
|
||||
OpenGLSurfaceEvaluator surfaceEvaluator;
|
||||
OpenGLCurveEvaluator curveEvaluator;
|
||||
|
||||
void loadSamplingMatrix( const GLfloat vmat[4][4],
|
||||
const GLint viewport[4] );
|
||||
void loadCullingMatrix( GLfloat vmat[4][4] );
|
||||
static void grabGLMatrix( GLfloat vmat[4][4] );
|
||||
static void transform4d( GLfloat A[4], GLfloat B[4],
|
||||
GLfloat mat[4][4] );
|
||||
static void multmatrix4d( GLfloat n[4][4], const GLfloat left[4][4],
|
||||
const GLfloat right[4][4] );
|
||||
|
||||
int callbackFlag;
|
||||
};
|
||||
|
||||
#endif /* __gluglrenderer_h_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,404 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glsurfeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluglsurfeval_h_
|
||||
#define __gluglsurfeval_h_
|
||||
|
||||
#include "basicsurfeval.h"
|
||||
#include "bezierPatchMesh.h" //in case output triangles
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
class SurfaceMap;
|
||||
class OpenGLSurfaceEvaluator;
|
||||
class StoredVertex;
|
||||
|
||||
#define TYPECOORD 1
|
||||
#define TYPEPOINT 2
|
||||
|
||||
/* Cache up to 3 vertices from tmeshes */
|
||||
#define VERTEX_CACHE_SIZE 3
|
||||
|
||||
/*for internal evaluator callback stuff*/
|
||||
#ifndef IN_MAX_BEZIER_ORDER
|
||||
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
|
||||
#endif
|
||||
|
||||
#ifndef IN_MAX_DIMENSION
|
||||
#define IN_MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
typedef struct surfEvalMachine{
|
||||
REAL uprime;//cached previusly evaluated uprime.
|
||||
REAL vprime;
|
||||
int k; /*the dimension*/
|
||||
REAL u1;
|
||||
REAL u2;
|
||||
int ustride;
|
||||
int uorder;
|
||||
REAL v1;
|
||||
REAL v2;
|
||||
int vstride;
|
||||
int vorder;
|
||||
REAL ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
REAL ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
|
||||
REAL vcoeff[IN_MAX_BEZIER_ORDER];
|
||||
REAL ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
|
||||
REAL vcoeffDeriv[IN_MAX_BEZIER_ORDER];
|
||||
} surfEvalMachine;
|
||||
|
||||
|
||||
|
||||
class StoredVertex {
|
||||
public:
|
||||
StoredVertex() { type = 0; }
|
||||
~StoredVertex(void) {}
|
||||
void saveEvalCoord(REAL x, REAL y)
|
||||
{coord[0] = x; coord[1] = y; type = TYPECOORD; }
|
||||
void saveEvalPoint(long x, long y)
|
||||
{point[0] = x; point[1] = y; type = TYPEPOINT; }
|
||||
void invoke(OpenGLSurfaceEvaluator *eval);
|
||||
|
||||
private:
|
||||
int type;
|
||||
REAL coord[2];
|
||||
long point[2];
|
||||
};
|
||||
|
||||
class OpenGLSurfaceEvaluator : public BasicSurfaceEvaluator {
|
||||
public:
|
||||
OpenGLSurfaceEvaluator();
|
||||
virtual ~OpenGLSurfaceEvaluator( void );
|
||||
void polymode( long style );
|
||||
void range2f( long, REAL *, REAL * );
|
||||
void domain2f( REAL, REAL, REAL, REAL );
|
||||
void addMap( SurfaceMap * ) { }
|
||||
|
||||
void enable( long );
|
||||
void disable( long );
|
||||
void bgnmap2f( long );
|
||||
void map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long, REAL * );
|
||||
void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
|
||||
void mapmesh2f( long, long, long, long, long );
|
||||
void evalcoord2f( long, REAL, REAL );
|
||||
void evalpoint2i( long, long );
|
||||
void endmap2f( void );
|
||||
|
||||
void bgnline( void );
|
||||
void endline( void );
|
||||
void bgnclosedline( void );
|
||||
void endclosedline( void );
|
||||
void bgntmesh( void );
|
||||
void swaptmesh( void );
|
||||
void endtmesh( void );
|
||||
void bgnqstrip( void );
|
||||
void endqstrip( void );
|
||||
|
||||
void bgntfan( void );
|
||||
void endtfan( void );
|
||||
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val);
|
||||
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val);
|
||||
|
||||
void coord2f( REAL, REAL );
|
||||
void point2i( long, long );
|
||||
|
||||
void newtmeshvert( REAL, REAL );
|
||||
void newtmeshvert( long, long );
|
||||
|
||||
#ifdef _WIN32
|
||||
void putCallBack(GLenum which, void (GLAPIENTRY *fn)() );
|
||||
#else
|
||||
void putCallBack(GLenum which, _GLUfuncptr fn );
|
||||
#endif
|
||||
|
||||
int get_vertices_call_back()
|
||||
{
|
||||
return output_triangles;
|
||||
}
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
output_triangles = flag;
|
||||
}
|
||||
|
||||
void put_callback_auto_normal(int flag)
|
||||
{
|
||||
callback_auto_normal = flag;
|
||||
}
|
||||
|
||||
int get_callback_auto_normal()
|
||||
{
|
||||
return callback_auto_normal;
|
||||
}
|
||||
|
||||
void set_callback_userData(void* data)
|
||||
{
|
||||
userData = data;
|
||||
}
|
||||
|
||||
/**************begin for LOD_eval_list***********/
|
||||
void LOD_eval_list(int level);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
StoredVertex *vertexCache[VERTEX_CACHE_SIZE];
|
||||
int tmeshing;
|
||||
int which;
|
||||
int vcount;
|
||||
|
||||
GLint gl_polygon_mode[2];/*to save and restore so that
|
||||
*no side effect
|
||||
*/
|
||||
bezierPatchMesh *global_bpm; //for output triangles
|
||||
int output_triangles; //true 1 or false 0
|
||||
|
||||
|
||||
|
||||
void (GLAPIENTRY *beginCallBackN) (GLenum type);
|
||||
void (GLAPIENTRY *endCallBackN) (void);
|
||||
void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
|
||||
void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
|
||||
void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
|
||||
void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
|
||||
void (GLAPIENTRY *endCallBackData) (void* data);
|
||||
void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
|
||||
void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
|
||||
void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
|
||||
void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
|
||||
|
||||
void beginCallBack (GLenum type, void* data);
|
||||
void endCallBack (void* data);
|
||||
void vertexCallBack (const GLfloat *vert, void* data);
|
||||
void normalCallBack (const GLfloat *normal, void* data);
|
||||
void colorCallBack (const GLfloat *color, void* data);
|
||||
void texcoordCallBack (const GLfloat *texcoord, void* data);
|
||||
|
||||
|
||||
void* userData; //the opaque pointer for Data callback functions.
|
||||
|
||||
/*LOD evaluation*/
|
||||
void LOD_triangle(REAL A[2], REAL B[2], REAL C[2],
|
||||
int level);
|
||||
void LOD_eval(int num_vert, REAL* verts, int type, int level);
|
||||
|
||||
int LOD_eval_level; //set by LOD_eval_list()
|
||||
|
||||
/*************begin for internal evaluators*****************/
|
||||
|
||||
/*the following global variables are only defined in this file.
|
||||
*They are used to cache the precomputed Bezier polynomial values.
|
||||
*These calues may be used consecutively in which case we don't have
|
||||
*recompute these values again.
|
||||
*/
|
||||
int global_uorder; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder; /*store the vorder in the previous evaluation*/
|
||||
REAL global_uprime;
|
||||
REAL global_vprime;
|
||||
REAL global_vprime_BV;
|
||||
REAL global_uprime_BU;
|
||||
int global_uorder_BV; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder_BV; /*store the vorder in the previous evaluation*/
|
||||
int global_uorder_BU; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder_BU; /*store the vorder in the previous evaluation*/
|
||||
|
||||
REAL global_ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
|
||||
REAL global_vcoeff[IN_MAX_BEZIER_ORDER];
|
||||
REAL global_ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
|
||||
REAL global_vcoeffDeriv[IN_MAX_BEZIER_ORDER];
|
||||
|
||||
REAL global_BV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_PBV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_BU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_PBU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL* global_baseData;
|
||||
|
||||
int global_ev_k; /*the dimension*/
|
||||
REAL global_ev_u1;
|
||||
REAL global_ev_u2;
|
||||
int global_ev_ustride;
|
||||
int global_ev_uorder;
|
||||
REAL global_ev_v1;
|
||||
REAL global_ev_v2;
|
||||
int global_ev_vstride;
|
||||
int global_ev_vorder;
|
||||
REAL global_ev_ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
|
||||
REAL global_grid_u0;
|
||||
REAL global_grid_u1;
|
||||
int global_grid_nu;
|
||||
REAL global_grid_v0;
|
||||
REAL global_grid_v1;
|
||||
int global_grid_nv;
|
||||
|
||||
/*functions*/
|
||||
void inDoDomain2WithDerivs(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL *retdu, REAL *retdv);
|
||||
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
|
||||
void inPreEvaluateWithDeriv(int order, REAL vprime, REAL *coeff, REAL *coeffDeriv);
|
||||
void inComputeFirstPartials(REAL *p, REAL *pu, REAL *pv);
|
||||
void inComputeNormal2(REAL *pu, REAL *pv, REAL *n);
|
||||
void inDoEvalCoord2(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
void inDoEvalCoord2NOGE(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
void inMap2f(int k,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL vlower,
|
||||
REAL vupper,
|
||||
int vstride,
|
||||
int vorder,
|
||||
REAL *ctlPoints);
|
||||
|
||||
void inMapGrid2f(int nu, REAL u0, REAL u1,
|
||||
int nv, REAL v0, REAL v1);
|
||||
|
||||
void inEvalMesh2(int lowU, int lowV, int highU, int highV);
|
||||
void inEvalPoint2(int i, int j);
|
||||
void inEvalCoord2f(REAL u, REAL v);
|
||||
|
||||
void inEvalULine(int n_points, REAL v, REAL* u_vals,
|
||||
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
|
||||
|
||||
void inEvalVLine(int n_points, REAL u, REAL* v_vals,
|
||||
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
|
||||
|
||||
void inEvalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
);
|
||||
void inEvalVStrip(int n_left, REAL u_left, REAL* left_val, int n_right, REAL u_right, REAL* right_val);
|
||||
|
||||
void inPreEvaluateBV(int k, int uorder, int vorder, REAL vprime, REAL *baseData);
|
||||
void inPreEvaluateBU(int k, int uorder, int vorder, REAL uprime, REAL *baseData);
|
||||
void inPreEvaluateBV_intfac(REAL v )
|
||||
{
|
||||
inPreEvaluateBV(global_ev_k, global_ev_uorder, global_ev_vorder, (v-global_ev_v1)/(global_ev_v2-global_ev_v1), global_ev_ctlPoints);
|
||||
}
|
||||
|
||||
void inPreEvaluateBU_intfac(REAL u)
|
||||
{
|
||||
inPreEvaluateBU(global_ev_k, global_ev_uorder, global_ev_vorder, (u-global_ev_u1)/(global_ev_u2-global_ev_u1), global_ev_ctlPoints);
|
||||
}
|
||||
|
||||
void inDoDomain2WithDerivsBV(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL* retdu, REAL *retdv);
|
||||
|
||||
void inDoDomain2WithDerivsBU(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL* retdu, REAL *retdv);
|
||||
|
||||
|
||||
void inDoEvalCoord2NOGE_BV(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
|
||||
void inDoEvalCoord2NOGE_BU(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
|
||||
void inBPMEval(bezierPatchMesh* bpm);
|
||||
void inBPMListEval(bezierPatchMesh* list);
|
||||
|
||||
/*-------------begin for surfEvalMachine -------------*/
|
||||
surfEvalMachine em_vertex;
|
||||
surfEvalMachine em_normal;
|
||||
surfEvalMachine em_color;
|
||||
surfEvalMachine em_texcoord;
|
||||
|
||||
int auto_normal_flag; //whether to output normla or not in callback
|
||||
//determined by GL_AUTO_NORMAL and callback_auto_normal
|
||||
int callback_auto_normal; //GLU_CALLBACK_AUTO_NORMAL_EXT
|
||||
int vertex_flag;
|
||||
int normal_flag;
|
||||
int color_flag;
|
||||
int texcoord_flag;
|
||||
|
||||
void inMap2fEM(int which, //0:vert,1:norm,2:color,3:tex
|
||||
int dimension,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL vlower,
|
||||
REAL vupper,
|
||||
int vstride,
|
||||
int vorder,
|
||||
REAL *ctlPoints);
|
||||
|
||||
void inDoDomain2WithDerivsEM(surfEvalMachine *em, REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retdu, REAL *retdv);
|
||||
void inDoDomain2EM(surfEvalMachine *em, REAL u, REAL v,
|
||||
REAL *retPoint);
|
||||
void inDoEvalCoord2EM(REAL u, REAL v);
|
||||
|
||||
void inBPMEvalEM(bezierPatchMesh* bpm);
|
||||
void inBPMListEvalEM(bezierPatchMesh* list);
|
||||
|
||||
/*-------------end for surfEvalMachine -------------*/
|
||||
|
||||
|
||||
/*************end for internal evaluators*****************/
|
||||
|
||||
};
|
||||
|
||||
inline void StoredVertex::invoke(OpenGLSurfaceEvaluator *eval)
|
||||
{
|
||||
switch(type) {
|
||||
case TYPECOORD:
|
||||
eval->coord2f(coord[0], coord[1]);
|
||||
break;
|
||||
case TYPEPOINT:
|
||||
eval->point2i(point[0], point[1]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __gluglsurfeval_h_ */
|
|
@ -1,206 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glcurveval.h"
|
||||
|
||||
|
||||
/*
|
||||
*compute the Bezier polynomials C[n,j](v) for all j at v with
|
||||
*return values stored in coeff[], where
|
||||
* C[n,j](v) = (n,j) * v^j * (1-v)^(n-j),
|
||||
* j=0,1,2,...,n.
|
||||
*order : n+1
|
||||
*vprime: v
|
||||
*coeff : coeff[j]=C[n,j](v), this array store the returned values.
|
||||
*The algorithm is a recursive scheme:
|
||||
* C[0,0]=1;
|
||||
* C[n,j](v) = (1-v)*C[n-1,j](v) + v*C[n-1,j-1](v), n>=1
|
||||
*This code is copied from opengl/soft/so_eval.c:PreEvaluate
|
||||
*/
|
||||
void OpenGLCurveEvaluator::inPreEvaluate(int order, REAL vprime, REAL *coeff)
|
||||
{
|
||||
int i, j;
|
||||
REAL oldval, temp;
|
||||
REAL oneMinusvprime;
|
||||
|
||||
/*
|
||||
* Minor optimization
|
||||
* Compute orders 1 and 2 outright, and set coeff[0], coeff[1] to
|
||||
* their i==1 loop values to avoid the initialization and the i==1 loop.
|
||||
*/
|
||||
if (order == 1) {
|
||||
coeff[0] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
oneMinusvprime = 1-vprime;
|
||||
coeff[0] = oneMinusvprime;
|
||||
coeff[1] = vprime;
|
||||
if (order == 2) return;
|
||||
|
||||
for (i = 2; i < order; i++) {
|
||||
oldval = coeff[0] * vprime;
|
||||
coeff[0] = oneMinusvprime * coeff[0];
|
||||
for (j = 1; j < i; j++) {
|
||||
temp = oldval;
|
||||
oldval = coeff[j] * vprime;
|
||||
coeff[j] = temp + oneMinusvprime * coeff[j];
|
||||
}
|
||||
coeff[j] = oldval;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
|
||||
int k, //dimension
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL *ctlpoints)
|
||||
{
|
||||
int i,x;
|
||||
curveEvalMachine *temp_em;
|
||||
switch(which){
|
||||
case 0: //vertex
|
||||
vertex_flag = 1;
|
||||
temp_em = &em_vertex;
|
||||
break;
|
||||
case 1: //normal
|
||||
normal_flag = 1;
|
||||
temp_em = &em_normal;
|
||||
break;
|
||||
case 2: //color
|
||||
color_flag = 1;
|
||||
temp_em = &em_color;
|
||||
break;
|
||||
default:
|
||||
texcoord_flag = 1;
|
||||
temp_em = &em_texcoord;
|
||||
break;
|
||||
}
|
||||
|
||||
REAL *data = temp_em->ctlpoints;
|
||||
temp_em->uprime = -1; //initialized
|
||||
temp_em->k = k;
|
||||
temp_em->u1 = ulower;
|
||||
temp_em->u2 = uupper;
|
||||
temp_em->ustride = ustride;
|
||||
temp_em->uorder = uorder;
|
||||
/*copy the control points*/
|
||||
for(i=0; i<uorder; i++){
|
||||
for(x=0; x<k; x++){
|
||||
data[x] = ctlpoints[x];
|
||||
}
|
||||
ctlpoints += ustride;
|
||||
data += k;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint)
|
||||
{
|
||||
int j, row;
|
||||
REAL the_uprime;
|
||||
REAL *data;
|
||||
|
||||
if(em->u2 == em->u1)
|
||||
return;
|
||||
the_uprime = (u-em->u1) / (em->u2-em->u1);
|
||||
/*use already cached values if possible*/
|
||||
if(em->uprime != the_uprime){
|
||||
inPreEvaluate(em->uorder, the_uprime, em->ucoeff);
|
||||
em->uprime = the_uprime;
|
||||
}
|
||||
|
||||
for(j=0; j<em->k; j++){
|
||||
data = em->ctlpoints+j;
|
||||
retPoint[j] = 0.0;
|
||||
for(row=0; row<em->uorder; row++)
|
||||
{
|
||||
retPoint[j] += em->ucoeff[row] * (*data);
|
||||
data += em->k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inDoEvalCoord1(REAL u)
|
||||
{
|
||||
REAL temp_vertex[4];
|
||||
REAL temp_normal[3];
|
||||
REAL temp_color[4];
|
||||
REAL temp_texcoord[4];
|
||||
if(texcoord_flag) //there is a texture map
|
||||
{
|
||||
inDoDomain1(&em_texcoord, u, temp_texcoord);
|
||||
texcoordCallBack(temp_texcoord, userData);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("color_flag = %i\n", color_flag);
|
||||
#endif
|
||||
if(color_flag) //there is a color map
|
||||
{
|
||||
inDoDomain1(&em_color, u, temp_color);
|
||||
colorCallBack(temp_color, userData);
|
||||
}
|
||||
if(normal_flag) //there is a normal map
|
||||
{
|
||||
inDoDomain1(&em_normal, u, temp_normal);
|
||||
normalCallBack(temp_normal, userData);
|
||||
}
|
||||
if(vertex_flag)
|
||||
{
|
||||
inDoDomain1(&em_vertex, u, temp_vertex);
|
||||
vertexCallBack(temp_vertex, userData);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inMapMesh1f(int umin, int umax)
|
||||
{
|
||||
REAL du, u;
|
||||
int i;
|
||||
if(global_grid_nu == 0)
|
||||
return; //no points to output
|
||||
du = (global_grid_u1 - global_grid_u0) / (REAL) global_grid_nu;
|
||||
bgnline();
|
||||
for(i=umin; i<= umax; i++){
|
||||
u = (i==global_grid_nu)? global_grid_u1: global_grid_u0 + i*du;
|
||||
inDoEvalCoord1(u);
|
||||
}
|
||||
endline();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystdio.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumystdio_h_
|
||||
#define __glumystdio_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
inline void _glu_dprintf( const char *, ... ) { }
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#ifndef NDEBUG
|
||||
#include <stdio.h>
|
||||
#define _glu_dprintf printf
|
||||
#else
|
||||
inline void _glu_dprintf( const char *, ... ) { }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
inline void _glu_dprintf( const char *, ... ) { }
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* __glumystdio_h_ */
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystdlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumystdlib_h_
|
||||
#define __glumystdlib_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void abort( void );
|
||||
extern "C" void * malloc( size_t );
|
||||
extern "C" void free( void * );
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void abort( void );
|
||||
extern "C" void * malloc( size_t );
|
||||
extern "C" void free( void * );
|
||||
#endif
|
||||
|
||||
#endif /* __glumystdlib_h_ */
|
|
@ -1,347 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arc.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "bin.h"
|
||||
#include "bezierarc.h"
|
||||
#include "pwlarc.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
/* local preprocessor definitions */
|
||||
#define ZERO 0.00001/*0.000001*/
|
||||
|
||||
const int Arc::bezier_tag = (1<<13);
|
||||
const int Arc::arc_tag = (1<<3);
|
||||
const int Arc::tail_tag = (1<<6);
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* makeSide - attach a pwl arc to an arc and mark it as a border arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::makeSide( PwlArc *pwl, arc_side side )
|
||||
{
|
||||
assert( pwl != 0);
|
||||
assert( pwlArc == 0 );
|
||||
assert( pwl->npts > 0 );
|
||||
assert( pwl->pts != 0);
|
||||
pwlArc = pwl;
|
||||
clearbezier();
|
||||
setside( side );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* numpts - count number of points on arc loop
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::numpts( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
int npts = 0;
|
||||
do {
|
||||
npts += jarc->pwlArc->npts;
|
||||
jarc = jarc->next;
|
||||
} while( jarc != this );
|
||||
return npts;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* markverts - mark each point with id of arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::markverts( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
|
||||
do {
|
||||
TrimVertex *p = jarc->pwlArc->pts;
|
||||
for( int i=0; i<jarc->pwlArc->npts; i++ )
|
||||
p[i].nuid = jarc->nuid;
|
||||
jarc = jarc->next;
|
||||
} while( jarc != this );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* getextrema - find axis extrema on arc loop
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::getextrema( Arc_ptr extrema[4] )
|
||||
{
|
||||
REAL leftpt, botpt, rightpt, toppt;
|
||||
|
||||
extrema[0] = extrema[1] = extrema[2] = extrema[3] = this;
|
||||
|
||||
leftpt = rightpt = this->tail()[0];
|
||||
botpt = toppt = this->tail()[1];
|
||||
|
||||
for( Arc_ptr jarc = this->next; jarc != this; jarc = jarc->next ) {
|
||||
if ( jarc->tail()[0] < leftpt ||
|
||||
(jarc->tail()[0] <= leftpt && jarc->rhead()[0]<=leftpt)) {
|
||||
leftpt = jarc->pwlArc->pts->param[0];
|
||||
extrema[1] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[0] > rightpt ||
|
||||
(jarc->tail()[0] >= rightpt && jarc->rhead()[0] >= rightpt)) {
|
||||
rightpt = jarc->pwlArc->pts->param[0];
|
||||
extrema[3] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[1] < botpt ||
|
||||
(jarc->tail()[1] <= botpt && jarc->rhead()[1] <= botpt )) {
|
||||
botpt = jarc->pwlArc->pts->param[1];
|
||||
extrema[2] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[1] > toppt ||
|
||||
(jarc->tail()[1] >= toppt && jarc->rhead()[1] >= toppt)) {
|
||||
toppt = jarc->pwlArc->pts->param[1];
|
||||
extrema[0] = jarc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* show - print to the stdout the vertices of a pwl arc
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::show()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "\tPWLARC NP: %d FL: 1\n", pwlArc->npts );
|
||||
for( int i = 0; i < pwlArc->npts; i++ ) {
|
||||
_glu_dprintf( "\t\tVERTEX %f %f\n", pwlArc->pts[i].param[0],
|
||||
pwlArc->pts[i].param[1] );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* print - print out the vertices of all pwl arcs on a loop
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::print( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "BGNTRIM\n" );
|
||||
#endif
|
||||
do {
|
||||
jarc->show( );
|
||||
jarc = jarc->next;
|
||||
} while (jarc != this);
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf("ENDTRIM\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* isDisconnected - check if tail of arc and head of prev meet
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::isDisconnected( void )
|
||||
{
|
||||
if( pwlArc == 0 ) return 0;
|
||||
if( prev->pwlArc == 0 ) return 0;
|
||||
|
||||
REAL *p0 = tail();
|
||||
REAL *p1 = prev->rhead();
|
||||
|
||||
if( ((p0[0] - p1[0]) > ZERO) || ((p1[0] - p0[0]) > ZERO) ||
|
||||
((p0[1] - p1[1]) > ZERO) || ((p1[1] - p0[1]) > ZERO) ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "x coord = %f %f %f\n", p0[0], p1[0], p0[0] - p1[0] );
|
||||
_glu_dprintf( "y coord = %f %f %f\n", p0[1], p1[1], p0[1] - p1[1] );
|
||||
#endif
|
||||
return 1;
|
||||
} else {
|
||||
/* average two points together */
|
||||
p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5;
|
||||
p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* neq_vert - assert that two 2D vertices are not equal
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
neq_vert( REAL *v1, REAL *v2 )
|
||||
{
|
||||
return ((v1[0] != v2[0]) || (v1[1] != v2[1] )) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* check - verify consistency of a loop, including
|
||||
* 1) if pwl, no two consecutive vertices are identical
|
||||
* 2) the circular link pointers are valid
|
||||
* 3) the geometric info at the head and tail are consistent
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::check( void )
|
||||
{
|
||||
if( this == 0 ) return 1;
|
||||
Arc_ptr jarc = this;
|
||||
do {
|
||||
assert( (jarc->pwlArc != 0) || (jarc->bezierArc != 0) );
|
||||
|
||||
if (jarc->prev == 0 || jarc->next == 0) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc:null next/prev pointer\n");
|
||||
jarc->print( );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (jarc->next->prev != jarc) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: pointer linkage screwed up\n");
|
||||
jarc->print( );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( jarc->pwlArc ) {
|
||||
#ifndef NDEBUG
|
||||
assert( jarc->pwlArc->npts >= 1 );
|
||||
assert( jarc->pwlArc->npts < 100000 );
|
||||
/*
|
||||
for( int i=0; i < jarc->pwlArc->npts-1; i++ )
|
||||
assert( neq_vert( jarc->pwlArc->pts[i].param,
|
||||
jarc->pwlArc->pts[i+1].param) );
|
||||
*/
|
||||
#endif
|
||||
if( jarc->prev->pwlArc ) {
|
||||
if( jarc->tail()[1] != jarc->prev->rhead()[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 1\n");
|
||||
jarc->prev->show();
|
||||
jarc->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if( jarc->tail()[0] != jarc->prev->rhead()[0] ) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 2\n");
|
||||
jarc->prev->show();
|
||||
jarc->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( jarc->next->pwlArc ) {
|
||||
if( jarc->next->tail()[0] != jarc->rhead()[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 3\n");
|
||||
jarc->show();
|
||||
jarc->next->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if( jarc->next->tail()[1] != jarc->rhead()[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 4\n");
|
||||
jarc->show();
|
||||
jarc->next->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( jarc->isbezier() ) {
|
||||
assert( jarc->pwlArc->npts == 2 );
|
||||
assert( (jarc->pwlArc->pts[0].param[0] == \
|
||||
jarc->pwlArc->pts[1].param[0]) ||\
|
||||
(jarc->pwlArc->pts[0].param[1] == \
|
||||
jarc->pwlArc->pts[1].param[1]) );
|
||||
}
|
||||
}
|
||||
jarc = jarc->next;
|
||||
} while (jarc != this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#define TOL 0.00001
|
||||
|
||||
inline long tooclose( REAL x, REAL y )
|
||||
{
|
||||
return (glu_abs(x-y) < TOL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* append - append a jordan arc to a circularly linked list
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Arc_ptr
|
||||
Arc::append( Arc_ptr jarc )
|
||||
{
|
||||
if( jarc != 0 ) {
|
||||
next = jarc->next;
|
||||
prev = jarc;
|
||||
next->prev = prev->next = this;
|
||||
} else {
|
||||
next = prev = this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarc_h_
|
||||
#define __gluarc_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "bufpool.h"
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "pwlarc.h"
|
||||
#include "trimvertex.h"
|
||||
|
||||
class Bin;
|
||||
class Arc;
|
||||
struct BezierArc;
|
||||
|
||||
typedef class Arc *Arc_ptr;
|
||||
|
||||
enum arc_side { arc_none = 0, arc_right, arc_top, arc_left, arc_bottom };
|
||||
|
||||
|
||||
class Arc: public PooledObj { /* an arc, in two list, the trim list and bin */
|
||||
|
||||
public:
|
||||
static const int bezier_tag;
|
||||
static const int arc_tag;
|
||||
static const int tail_tag;
|
||||
Arc_ptr prev; /* trim list pointer */
|
||||
Arc_ptr next; /* trim list pointer */
|
||||
Arc_ptr link; /* bin pointers */
|
||||
BezierArc * bezierArc; /* associated bezier arc */
|
||||
PwlArc * pwlArc; /* associated pwl arc */
|
||||
long type; /* curve type */
|
||||
long nuid;
|
||||
|
||||
inline Arc( Arc *, PwlArc * );
|
||||
inline Arc( arc_side, long );
|
||||
|
||||
Arc_ptr append( Arc_ptr );
|
||||
int check( void );
|
||||
int isMonotone( void );
|
||||
int isDisconnected( void );
|
||||
int numpts( void );
|
||||
void markverts( void );
|
||||
void getextrema( Arc_ptr[4] );
|
||||
void print( void );
|
||||
void show( void );
|
||||
void makeSide( PwlArc *, arc_side );
|
||||
inline int isTessellated() { return pwlArc ? 1 : 0; }
|
||||
inline long isbezier() { return type & bezier_tag; }
|
||||
inline void setbezier() { type |= bezier_tag; }
|
||||
inline void clearbezier() { type &= ~bezier_tag; }
|
||||
inline long npts() { return pwlArc->npts; }
|
||||
inline TrimVertex * pts() { return pwlArc->pts; }
|
||||
inline REAL * tail() { return pwlArc->pts[0].param; }
|
||||
inline REAL * head() { return next->pwlArc->pts[0].param; }
|
||||
inline REAL * rhead() { return pwlArc->pts[pwlArc->npts-1].param; }
|
||||
inline long ismarked() { return type & arc_tag; }
|
||||
inline void setmark() { type |= arc_tag; }
|
||||
inline void clearmark() { type &= (~arc_tag); }
|
||||
inline void clearside() { type &= ~(0x7 << 8); }
|
||||
inline void setside( arc_side s ) { clearside(); type |= (((long)s)<<8); }
|
||||
inline arc_side getside() { return (arc_side) ((type>>8) & 0x7); }
|
||||
inline int getitail() { return type & tail_tag; }
|
||||
inline void setitail() { type |= tail_tag; }
|
||||
inline void clearitail() { type &= (~tail_tag); }
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Arc - initialize a new Arc with the same type and uid of
|
||||
* a given Arc and a given pwl arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline
|
||||
Arc::Arc( Arc *j, PwlArc *p )
|
||||
{
|
||||
bezierArc = NULL;
|
||||
pwlArc = p;
|
||||
type = j->type;
|
||||
nuid = j->nuid;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Arc - initialize a new Arc with the same type and uid of
|
||||
* a given Arc and a given pwl arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline
|
||||
Arc::Arc( arc_side side, long _nuid )
|
||||
{
|
||||
bezierArc = NULL;
|
||||
pwlArc = NULL;
|
||||
type = 0;
|
||||
setside( side );
|
||||
nuid = _nuid;
|
||||
}
|
||||
|
||||
#endif /* __gluarc_h_ */
|
|
@ -1,172 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arcsorter.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarcsorter_c_
|
||||
#define __gluarcsorter_c_
|
||||
|
||||
#include "glimports.h"
|
||||
#include "arc.h"
|
||||
#include "arcsorter.h"
|
||||
#include "subdivider.h"
|
||||
|
||||
ArcSorter::ArcSorter(Subdivider &s) : Sorter( sizeof( Arc ** ) ), subdivider(s)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ArcSorter::qscmp( char *, char * )
|
||||
{
|
||||
_glu_dprintf( "ArcSorter::qscmp: pure virtual called\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qsort( Arc **a, int n )
|
||||
{
|
||||
Sorter::qsort( (void *) a, n );
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qsexc( char *i, char *j )// i<-j, j<-i
|
||||
{
|
||||
Arc **jarc1 = (Arc **) i;
|
||||
Arc **jarc2 = (Arc **) j;
|
||||
Arc *tmp = *jarc1;
|
||||
*jarc1 = *jarc2;
|
||||
*jarc2 = tmp;
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qstexc( char *i, char *j, char *k )// i<-k, k<-j, j<-i
|
||||
{
|
||||
Arc **jarc1 = (Arc **) i;
|
||||
Arc **jarc2 = (Arc **) j;
|
||||
Arc **jarc3 = (Arc **) k;
|
||||
Arc *tmp = *jarc1;
|
||||
*jarc1 = *jarc3;
|
||||
*jarc3 = *jarc2;
|
||||
*jarc2 = tmp;
|
||||
}
|
||||
|
||||
|
||||
ArcSdirSorter::ArcSdirSorter( Subdivider &s ) : ArcSorter(s)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ArcSdirSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
Arc *jarc1 = *(Arc **) i;
|
||||
Arc *jarc2 = *(Arc **) j;
|
||||
|
||||
int v1 = (jarc1->getitail() ? 0 : (jarc1->pwlArc->npts - 1));
|
||||
int v2 = (jarc2->getitail() ? 0 : (jarc2->pwlArc->npts - 1));
|
||||
|
||||
REAL diff = jarc1->pwlArc->pts[v1].param[1] -
|
||||
jarc2->pwlArc->pts[v2].param[1];
|
||||
|
||||
if( diff < 0.0)
|
||||
return -1;
|
||||
else if( diff > 0.0)
|
||||
return 1;
|
||||
else {
|
||||
if( v1 == 0 ) {
|
||||
if( jarc2->tail()[0] < jarc1->tail()[0] ) {
|
||||
return subdivider.ccwTurn_sl( jarc2, jarc1 ) ? 1 : -1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_sr( jarc2, jarc1 ) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if( jarc2->head()[0] < jarc1->head()[0] ) {
|
||||
return subdivider.ccwTurn_sl( jarc1, jarc2 ) ? -1 : 1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_sr( jarc1, jarc2 ) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArcTdirSorter::ArcTdirSorter( Subdivider &s ) : ArcSorter(s)
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ArcTdirSorter::qscmp -
|
||||
* compare two axis monotone arcs that are incident
|
||||
* to the line T == compare_value. Determine which of the
|
||||
* two intersects that line with a LESSER S value. If
|
||||
* jarc1 does, return 1. If jarc2 does, return -1.
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
ArcTdirSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
Arc *jarc1 = *(Arc **) i;
|
||||
Arc *jarc2 = *(Arc **) j;
|
||||
|
||||
int v1 = (jarc1->getitail() ? 0 : (jarc1->pwlArc->npts - 1));
|
||||
int v2 = (jarc2->getitail() ? 0 : (jarc2->pwlArc->npts - 1));
|
||||
|
||||
REAL diff = jarc1->pwlArc->pts[v1].param[0] -
|
||||
jarc2->pwlArc->pts[v2].param[0];
|
||||
|
||||
if( diff < 0.0)
|
||||
return 1;
|
||||
else if( diff > 0.0)
|
||||
return -1;
|
||||
else {
|
||||
if( v1 == 0 ) {
|
||||
if (jarc2->tail()[1] < jarc1->tail()[1]) {
|
||||
return subdivider.ccwTurn_tl( jarc2, jarc1 ) ? 1 : -1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_tr( jarc2, jarc1 ) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if( jarc2->head()[1] < jarc1->head()[1] ) {
|
||||
return subdivider.ccwTurn_tl( jarc1, jarc2 ) ? -1 : 1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_tr( jarc1, jarc2 ) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* __gluarcsorter_c_ */
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arcsorter.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarcsorter_h_
|
||||
#define __gluarcsorter_h_
|
||||
|
||||
#include "sorter.h"
|
||||
#include "arcsorter.h"
|
||||
|
||||
class Arc;
|
||||
class Subdivider;
|
||||
|
||||
class ArcSorter : private Sorter {
|
||||
public:
|
||||
ArcSorter(Subdivider &);
|
||||
void qsort( Arc **a, int n );
|
||||
protected:
|
||||
virtual int qscmp( char *, char * );
|
||||
Subdivider& subdivider;
|
||||
private:
|
||||
void qsexc( char *i, char *j ); // i<-j, j<-i
|
||||
void qstexc( char *i, char *j, char *k ); // i<-k, k<-j, j<-i
|
||||
};
|
||||
|
||||
|
||||
class ArcSdirSorter : public ArcSorter {
|
||||
public:
|
||||
ArcSdirSorter( Subdivider & );
|
||||
private:
|
||||
int qscmp( char *, char * );
|
||||
};
|
||||
|
||||
|
||||
class ArcTdirSorter : public ArcSorter {
|
||||
public:
|
||||
ArcTdirSorter( Subdivider & );
|
||||
private:
|
||||
int qscmp( char *, char * );
|
||||
};
|
||||
|
||||
#endif /* __gluarcsorter_h_ */
|
|
@ -1,611 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arctessellator.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arctess.h"
|
||||
#include "bufpool.h"
|
||||
#include "simplemath.h"
|
||||
#include "bezierarc.h"
|
||||
#include "trimvertex.h"
|
||||
#include "trimvertpool.h"
|
||||
|
||||
#define NOELIMINATION
|
||||
|
||||
#define steps_function(large, small, rate) (max(1, 1+ (int) ((large-small)/rate)));
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ArcTessellator - construct an ArcTessellator
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ArcTessellator::ArcTessellator( TrimVertexPool& t, Pool& p )
|
||||
: pwlarcpool(p), trimvertexpool(t)
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ~ArcTessellator - destroy an ArcTessellator
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ArcTessellator::~ArcTessellator( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* bezier - construct a bezier arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::bezier( Arc *arc, REAL s1, REAL s2, REAL t1, REAL t2 )
|
||||
{
|
||||
assert( arc != 0 );
|
||||
assert( ! arc->isTessellated() );
|
||||
|
||||
#ifndef NDEBUG
|
||||
switch( arc->getside() ) {
|
||||
case arc_left:
|
||||
assert( s1 == s2 );
|
||||
assert( t2 < t1 );
|
||||
break;
|
||||
case arc_right:
|
||||
assert( s1 == s2 );
|
||||
assert( t1 < t2 );
|
||||
break;
|
||||
case arc_top:
|
||||
assert( t1 == t2 );
|
||||
assert( s2 < s1 );
|
||||
break;
|
||||
case arc_bottom:
|
||||
assert( t1 == t2 );
|
||||
assert( s1 < s2 );
|
||||
break;
|
||||
case arc_none:
|
||||
(void) abort();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
TrimVertex *p = trimvertexpool.get(2);
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc( 2, p );
|
||||
p[0].param[0] = s1;
|
||||
p[0].param[1] = t1;
|
||||
p[1].param[0] = s2;
|
||||
p[1].param[1] = t2;
|
||||
assert( (s1 == s2) || (t1 == t2) );
|
||||
arc->setbezier();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_left - construct a left boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_left( Arc *arc, REAL s, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
assert( t2 < t1 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
/* int nsteps = 1 + (int) ((t1 - t2) / rate ); */
|
||||
int nsteps = steps_function(t1, t2, rate);
|
||||
|
||||
|
||||
REAL stepsize = (t1 - t2) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = nsteps; i > 0; i-- ) {
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t2;
|
||||
t2 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t1;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_left );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_right - construct a right boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_right( Arc *arc, REAL s, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
assert( t1 < t2 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((t2 - t1) / rate ); */
|
||||
int nsteps = steps_function(t2,t1,rate);
|
||||
REAL stepsize = (t2 - t1) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t1;
|
||||
t1 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t2;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_right );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_top - construct a top boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_top( Arc *arc, REAL t, REAL s1, REAL s2, REAL rate )
|
||||
{
|
||||
assert( s2 < s1 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((s1 - s2) / rate ); */
|
||||
int nsteps = steps_function(s1,s2,rate);
|
||||
REAL stepsize = (s1 - s2) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = nsteps; i > 0; i-- ) {
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t;
|
||||
s2 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_top );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_bottom - construct a bottom boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_bottom( Arc *arc, REAL t, REAL s1, REAL s2, REAL rate )
|
||||
{
|
||||
assert( s1 < s2 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((s2 - s1) / rate ); */
|
||||
int nsteps = steps_function(s2,s1,rate);
|
||||
REAL stepsize = (s2 - s1) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t;
|
||||
s1 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_bottom );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl - construct a pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl( Arc *arc, REAL s1, REAL s2, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
int snsteps = 1 + (int) (glu_abs(s2 - s1) / rate );
|
||||
int tnsteps = 1 + (int) (glu_abs(t2 - t1) / rate );
|
||||
int nsteps = max(1,max( snsteps, tnsteps ));
|
||||
|
||||
REAL sstepsize = (s2 - s1) / (REAL) nsteps;
|
||||
REAL tstepsize = (t2 - t1) / (REAL) nsteps;
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
long i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t1;
|
||||
s1 += sstepsize;
|
||||
t1 += tstepsize;
|
||||
}
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t2;
|
||||
|
||||
/* arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_bottom ); */
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc( nsteps+1, newvert );
|
||||
|
||||
arc->clearbezier();
|
||||
arc->clearside( );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* tessellateLinear - constuct a linear pwl arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::tessellateLinear( Arc *arc, REAL geo_stepsize, REAL arc_stepsize, int isrational )
|
||||
{
|
||||
assert( arc->pwlArc == NULL );
|
||||
REAL s1, s2, t1, t2;
|
||||
|
||||
//we don't need to scale by arc_stepsize if the trim curve
|
||||
//is piecewise linear. Reason: In pwl_right, pwl_left, pwl_top, pwl_left,
|
||||
//and pwl, the nsteps is computed by deltaU (or V) /stepsize.
|
||||
//The quantity deltaU/arc_stepsize doesn't have any meaning. And
|
||||
//it causes problems: see bug 517641
|
||||
REAL stepsize = geo_stepsize; /* * arc_stepsize*/;
|
||||
|
||||
BezierArc *b = arc->bezierArc;
|
||||
|
||||
if( isrational ) {
|
||||
s1 = b->cpts[0] / b->cpts[2];
|
||||
t1 = b->cpts[1] / b->cpts[2];
|
||||
s2 = b->cpts[b->stride+0] / b->cpts[b->stride+2];
|
||||
t2 = b->cpts[b->stride+1] / b->cpts[b->stride+2];
|
||||
} else {
|
||||
s1 = b->cpts[0];
|
||||
t1 = b->cpts[1];
|
||||
s2 = b->cpts[b->stride+0];
|
||||
t2 = b->cpts[b->stride+1];
|
||||
}
|
||||
if( s1 == s2 )
|
||||
if( t1 < t2 )
|
||||
pwl_right( arc, s1, t1, t2, stepsize );
|
||||
else
|
||||
pwl_left( arc, s1, t1, t2, stepsize );
|
||||
else if( t1 == t2 )
|
||||
if( s1 < s2 )
|
||||
pwl_bottom( arc, t1, s1, s2, stepsize );
|
||||
else
|
||||
pwl_top( arc, t1, s1, s2, stepsize );
|
||||
else
|
||||
pwl( arc, s1, s2, t1, t2, stepsize );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* tessellateNonlinear - constuct a nonlinear pwl arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::tessellateNonlinear( Arc *arc, REAL geo_stepsize, REAL arc_stepsize, int isrational )
|
||||
{
|
||||
assert( arc->pwlArc == NULL );
|
||||
|
||||
REAL stepsize = geo_stepsize * arc_stepsize;
|
||||
|
||||
BezierArc *bezierArc = arc->bezierArc;
|
||||
|
||||
REAL size; //bounding box size of the curve in UV
|
||||
{
|
||||
int i,j;
|
||||
REAL min_u, min_v, max_u,max_v;
|
||||
min_u = max_u = bezierArc->cpts[0];
|
||||
min_v = max_v = bezierArc->cpts[1];
|
||||
for(i=1, j=bezierArc->stride; i<bezierArc->order; i++, j+= bezierArc->stride)
|
||||
{
|
||||
if(bezierArc->cpts[j] < min_u)
|
||||
min_u = bezierArc->cpts[j];
|
||||
if(bezierArc->cpts[j] > max_u)
|
||||
max_u = bezierArc->cpts[j];
|
||||
if(bezierArc->cpts[j+1] < min_v)
|
||||
min_v = bezierArc->cpts[j+1];
|
||||
if(bezierArc->cpts[j+1] > max_v)
|
||||
max_v = bezierArc->cpts[j+1];
|
||||
}
|
||||
|
||||
size = max_u - min_u;
|
||||
if(size < max_v - min_v)
|
||||
size = max_v - min_v;
|
||||
}
|
||||
|
||||
/*int nsteps = 1 + (int) (1.0/stepsize);*/
|
||||
|
||||
int nsteps = (int) (size/stepsize);
|
||||
if(nsteps <=0)
|
||||
nsteps=1;
|
||||
|
||||
TrimVertex *vert = trimvertexpool.get( nsteps+1 );
|
||||
REAL dp = 1.0/nsteps;
|
||||
|
||||
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc();
|
||||
arc->pwlArc->pts = vert;
|
||||
|
||||
if( isrational ) {
|
||||
REAL pow_u[MAXORDER], pow_v[MAXORDER], pow_w[MAXORDER];
|
||||
trim_power_coeffs( bezierArc, pow_u, 0 );
|
||||
trim_power_coeffs( bezierArc, pow_v, 1 );
|
||||
trim_power_coeffs( bezierArc, pow_w, 2 );
|
||||
|
||||
/* compute first point exactly */
|
||||
REAL *b = bezierArc->cpts;
|
||||
vert->param[0] = b[0]/b[2];
|
||||
vert->param[1] = b[1]/b[2];
|
||||
|
||||
/* strength reduction on p = dp * step would introduce error */
|
||||
int step;
|
||||
#ifndef NOELIMINATION
|
||||
int ocanremove = 0;
|
||||
#endif
|
||||
register long order = bezierArc->order;
|
||||
for( step=1, ++vert; step<nsteps; step++, vert++ ) {
|
||||
register REAL p = dp * step;
|
||||
register REAL u = pow_u[0];
|
||||
register REAL v = pow_v[0];
|
||||
register REAL w = pow_w[0];
|
||||
for( register int i = 1; i < order; i++ ) {
|
||||
u = u * p + pow_u[i];
|
||||
v = v * p + pow_v[i];
|
||||
w = w * p + pow_w[i];
|
||||
}
|
||||
vert->param[0] = u/w;
|
||||
vert->param[1] = v/w;
|
||||
#ifndef NOELIMINATION
|
||||
REAL ds = glu_abs(vert[0].param[0] - vert[-1].param[0]);
|
||||
REAL dt = glu_abs(vert[0].param[1] - vert[-1].param[1]);
|
||||
int canremove = (ds<geo_stepsize && dt<geo_stepsize) ? 1 : 0;
|
||||
REAL ods=0.0, odt=0.0;
|
||||
|
||||
if( ocanremove && canremove ) {
|
||||
REAL nds = ds + ods;
|
||||
REAL ndt = dt + odt;
|
||||
if( nds<geo_stepsize && ndt<geo_stepsize ) {
|
||||
// remove previous point
|
||||
--vert;
|
||||
vert[0].param[0] = vert[1].param[0];
|
||||
vert[0].param[1] = vert[1].param[1];
|
||||
ods = nds;
|
||||
odt = ndt;
|
||||
ocanremove = 1;
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute last point exactly */
|
||||
b += (order - 1) * bezierArc->stride;
|
||||
vert->param[0] = b[0]/b[2];
|
||||
vert->param[1] = b[1]/b[2];
|
||||
|
||||
} else {
|
||||
REAL pow_u[MAXORDER], pow_v[MAXORDER];
|
||||
trim_power_coeffs( bezierArc, pow_u, 0 );
|
||||
trim_power_coeffs( bezierArc, pow_v, 1 );
|
||||
|
||||
/* compute first point exactly */
|
||||
REAL *b = bezierArc->cpts;
|
||||
vert->param[0] = b[0];
|
||||
vert->param[1] = b[1];
|
||||
|
||||
/* strength reduction on p = dp * step would introduce error */
|
||||
int step;
|
||||
#ifndef NOELIMINATION
|
||||
int ocanremove = 0;
|
||||
#endif
|
||||
register long order = bezierArc->order;
|
||||
for( step=1, ++vert; step<nsteps; step++, vert++ ) {
|
||||
register REAL p = dp * step;
|
||||
register REAL u = pow_u[0];
|
||||
register REAL v = pow_v[0];
|
||||
for( register int i = 1; i < bezierArc->order; i++ ) {
|
||||
u = u * p + pow_u[i];
|
||||
v = v * p + pow_v[i];
|
||||
}
|
||||
vert->param[0] = u;
|
||||
vert->param[1] = v;
|
||||
#ifndef NOELIMINATION
|
||||
REAL ds = glu_abs(vert[0].param[0] - vert[-1].param[0]);
|
||||
REAL dt = glu_abs(vert[0].param[1] - vert[-1].param[1]);
|
||||
int canremove = (ds<geo_stepsize && dt<geo_stepsize) ? 1 : 0;
|
||||
REAL ods=0.0, odt=0.0;
|
||||
|
||||
if( ocanremove && canremove ) {
|
||||
REAL nds = ds + ods;
|
||||
REAL ndt = dt + odt;
|
||||
if( nds<geo_stepsize && ndt<geo_stepsize ) {
|
||||
// remove previous point
|
||||
--vert;
|
||||
vert[0].param[0] = vert[1].param[0];
|
||||
vert[0].param[1] = vert[1].param[1];
|
||||
ods = nds;
|
||||
odt = ndt;
|
||||
ocanremove = 1;
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute last point exactly */
|
||||
b += (order - 1) * bezierArc->stride;
|
||||
vert->param[0] = b[0];
|
||||
vert->param[1] = b[1];
|
||||
}
|
||||
arc->pwlArc->npts = vert - arc->pwlArc->pts + 1;
|
||||
/*
|
||||
for( TrimVertex *vt=pwlArc->pts; vt != vert-1; vt++ ) {
|
||||
if( tooclose( vt[0].param[0], vt[1].param[0] ) )
|
||||
vt[1].param[0] = vt[0].param[0];
|
||||
if( tooclose( vt[0].param[1], vt[1].param[1] ) )
|
||||
vt[1].param[1] = vt[0].param[1];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
const REAL ArcTessellator::gl_Bernstein[][MAXORDER][MAXORDER] = {
|
||||
{
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 1, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -2, 1, 0, 0, 0, 0, 0 },
|
||||
{-2, 2, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 3, -3, 1, 0, 0, 0, 0 },
|
||||
{3, -6, 3, 0, 0, 0, 0, 0 },
|
||||
{-3, 3, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -4, 6, -4, 1, 0, 0, 0 },
|
||||
{-4, 12, -12, 4, 0, 0, 0, 0 },
|
||||
{6, -12, 6, 0, 0, 0, 0, 0 },
|
||||
{-4, 4, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 5, -10, 10, -5, 1, 0, 0 },
|
||||
{5, -20, 30, -20, 5, 0, 0, 0 },
|
||||
{-10, 30, -30, 10, 0, 0, 0, 0 },
|
||||
{10, -20, 10, 0, 0, 0, 0, 0 },
|
||||
{-5, 5, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -6, 15, -20, 15, -6, 1, 0 },
|
||||
{-6, 30, -60, 60, -30, 6, 0, 0 },
|
||||
{15, -60, 90, -60, 15, 0, 0, 0 },
|
||||
{-20, 60, -60, 20, 0, 0, 0, 0 },
|
||||
{15, -30, 15, 0, 0, 0, 0, 0 },
|
||||
{-6, 6, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 7, -21, 35, -35, 21, -7, 1 },
|
||||
{7, -42, 105, -140, 105, -42, 7, 0 },
|
||||
{-21, 105, -210, 210, -105, 21, 0, 0 },
|
||||
{35, -140, 210, -140, 35, 0, 0, 0 },
|
||||
{-35, 105, -105, 35, 0, 0, 0, 0 },
|
||||
{21, -42, 21, 0, 0, 0, 0, 0 },
|
||||
{-7, 7, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 }
|
||||
}};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* trim_power_coeffs - compute power basis coefficients from bezier coeffients
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ArcTessellator::trim_power_coeffs( BezierArc *bez_arc, REAL *p, int coord )
|
||||
{
|
||||
register int stride = bez_arc->stride;
|
||||
register int order = bez_arc->order;
|
||||
register REAL *base = bez_arc->cpts + coord;
|
||||
|
||||
REAL const (*mat)[MAXORDER][MAXORDER] = &gl_Bernstein[order-1];
|
||||
REAL const (*lrow)[MAXORDER] = &(*mat)[order];
|
||||
|
||||
/* WIN32 didn't like the following line within the for-loop */
|
||||
REAL const (*row)[MAXORDER] = &(*mat)[0];
|
||||
for( ; row != lrow; row++ ) {
|
||||
register REAL s = 0.0;
|
||||
register REAL *point = base;
|
||||
register REAL const *mlast = *row + order;
|
||||
for( REAL const *m = *row; m != mlast; m++, point += stride )
|
||||
s += *(m) * (*point);
|
||||
*(p++) = s;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arctess.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarctess_h_
|
||||
#define __gluarctess_h_
|
||||
|
||||
#include "defines.h"
|
||||
#include "types.h"
|
||||
#include "arc.h"
|
||||
|
||||
struct BezierArc;
|
||||
class Pool;
|
||||
class TrimVertexPool;
|
||||
|
||||
class ArcTessellator {
|
||||
public:
|
||||
ArcTessellator( TrimVertexPool&, Pool& );
|
||||
~ArcTessellator( void );
|
||||
void bezier( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl( Arc_ptr, REAL, REAL, REAL, REAL, REAL );
|
||||
void pwl_left( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_right( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_top( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_bottom( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void tessellateLinear( Arc_ptr, REAL, REAL, int );
|
||||
void tessellateNonlinear( Arc_ptr, REAL, REAL, int );
|
||||
private:
|
||||
static const REAL gl_Bernstein[][MAXORDER][MAXORDER];
|
||||
Pool& pwlarcpool;
|
||||
TrimVertexPool& trimvertexpool;
|
||||
static void trim_power_coeffs( BezierArc *, REAL[MAXORDER], int );
|
||||
};
|
||||
|
||||
#endif /* __gluarctess_h_ */
|
|
@ -1,589 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* backend.c++
|
||||
*
|
||||
*/
|
||||
|
||||
/* Bezier surface backend
|
||||
- interprets display mode (wireframe,shaded,...)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "backend.h"
|
||||
#include "basiccrveval.h"
|
||||
#include "basicsurfeval.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
#define NOWIREFRAME
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnsurf - preamble to surface definition and evaluations
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgnsurf( int wiretris, int wirequads, long nuid )
|
||||
{
|
||||
/*#ifndef NOWIREFRAME*/ //need this for old version
|
||||
wireframetris = wiretris;
|
||||
wireframequads = wirequads;
|
||||
/*#endif*/
|
||||
|
||||
/*in the spec, GLU_DISPLAY_MODE is either
|
||||
* GLU_FILL
|
||||
* GLU_OUTLINE_POLY
|
||||
* GLU_OUTLINE_PATCH.
|
||||
*In fact, GLU_FLL is has the same effect as
|
||||
* set GL_FRONT_AND_BACK to be GL_FILL
|
||||
* and GLU_OUTLINE_POLY is the same as set
|
||||
* GL_FRONT_AND_BACK to be GL_LINE
|
||||
*It is more efficient to do this once at the beginning of
|
||||
*each surface than to do it for each primitive.
|
||||
* The internal has more options: outline_triangle and outline_quad
|
||||
*can be seperated. But since this is not in spec, and more importantly,
|
||||
*this is not so useful, so we don't need to keep this option.
|
||||
*/
|
||||
|
||||
surfaceEvaluator.bgnmap2f( nuid );
|
||||
|
||||
if(wiretris)
|
||||
surfaceEvaluator.polymode(N_MESHLINE);
|
||||
else
|
||||
surfaceEvaluator.polymode(N_MESHFILL);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::patch( REAL ulo, REAL uhi, REAL vlo, REAL vhi )
|
||||
{
|
||||
surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::surfbbox( long type, REAL *from, REAL *to )
|
||||
{
|
||||
surfaceEvaluator.range2f( type, from, to );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* surfpts - pass a desription of a surface map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::surfpts(
|
||||
long type, /* geometry, color, texture, normal */
|
||||
REAL *pts, /* control points */
|
||||
long ustride, /* distance to next point in u direction */
|
||||
long vstride, /* distance to next point in v direction */
|
||||
int uorder, /* u parametric order */
|
||||
int vorder, /* v parametric order */
|
||||
REAL ulo, /* u lower bound */
|
||||
REAL uhi, /* u upper bound */
|
||||
REAL vlo, /* v lower bound */
|
||||
REAL vhi ) /* v upper bound */
|
||||
{
|
||||
surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
|
||||
surfaceEvaluator.enable( type );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* surfgrid - define a lattice of points with origin and offset
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::surfgrid( REAL u0, REAL u1, long nu, REAL v0, REAL v1, long nv )
|
||||
{
|
||||
surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* surfmesh - evaluate a mesh of points on lattice
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::surfmesh( long u, long v, long n, long m )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( wireframequads ) {
|
||||
long v0, v1;
|
||||
long u0f = u, u1f = u+n;
|
||||
long v0f = v, v1f = v+m;
|
||||
long parity = (u & 1);
|
||||
|
||||
for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) {
|
||||
surfaceEvaluator.bgnline();
|
||||
for( long u = u0f; u<=u1f; u++ ) {
|
||||
if( parity ) {
|
||||
surfaceEvaluator.evalpoint2i( u, v0 );
|
||||
surfaceEvaluator.evalpoint2i( u, v1 );
|
||||
} else {
|
||||
surfaceEvaluator.evalpoint2i( u, v1 );
|
||||
surfaceEvaluator.evalpoint2i( u, v0 );
|
||||
}
|
||||
parity = 1 - parity;
|
||||
}
|
||||
surfaceEvaluator.endline();
|
||||
}
|
||||
} else {
|
||||
surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
|
||||
}
|
||||
#else
|
||||
if( wireframequads ) {
|
||||
|
||||
surfaceEvaluator.mapmesh2f( N_MESHLINE, u, u+n, v, v+m );
|
||||
} else {
|
||||
|
||||
surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endsurf - postamble to surface
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endsurf( void )
|
||||
{
|
||||
surfaceEvaluator.endmap2f();
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
void
|
||||
Backend::bgntfan( void )
|
||||
{
|
||||
surfaceEvaluator.bgntfan();
|
||||
/*
|
||||
if(wireframetris)
|
||||
surfaceEvaluator.polymode( N_MESHLINE );
|
||||
else
|
||||
surfaceEvaluator.polymode( N_MESHFILL );
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endtfan( void )
|
||||
{
|
||||
surfaceEvaluator.endtfan();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgnqstrip( void )
|
||||
{
|
||||
surfaceEvaluator.bgnqstrip();
|
||||
/*
|
||||
if(wireframequads)
|
||||
surfaceEvaluator.polymode( N_MESHLINE );
|
||||
else
|
||||
surfaceEvaluator.polymode( N_MESHFILL );
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endqstrip( void )
|
||||
{
|
||||
surfaceEvaluator.endqstrip();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
)
|
||||
{
|
||||
surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val,
|
||||
n_lower, v_lower, lower_val);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val
|
||||
)
|
||||
{
|
||||
surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
|
||||
n_right, u_right, right_val);
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgntmesh - preamble to a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgntmesh( const char * )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
|
||||
meshindex = 0; /* I think these need to be initialized to zero */
|
||||
npts = 0;
|
||||
|
||||
if( !wireframetris ) {
|
||||
surfaceEvaluator.bgntmesh();
|
||||
}
|
||||
#else
|
||||
|
||||
if( wireframetris ) {
|
||||
surfaceEvaluator.bgntmesh();
|
||||
surfaceEvaluator.polymode( N_MESHLINE );
|
||||
} else {
|
||||
surfaceEvaluator.bgntmesh();
|
||||
surfaceEvaluator.polymode( N_MESHFILL );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Backend::tmeshvert( GridTrimVertex *v )
|
||||
{
|
||||
if( v->isGridVert() ) {
|
||||
tmeshvert( v->g );
|
||||
} else {
|
||||
tmeshvert( v->t );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Backend::tmeshvertNOGE(TrimVertex *t)
|
||||
{
|
||||
// surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], temp, ttt);
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
//opt for a line with the same u.
|
||||
void
|
||||
Backend::tmeshvertNOGE_BU(TrimVertex *t)
|
||||
{
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE_BU( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
//opt for a line with the same v.
|
||||
void
|
||||
Backend::tmeshvertNOGE_BV(TrimVertex *t)
|
||||
{
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE_BV( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Backend::preEvaluateBU(REAL u)
|
||||
{
|
||||
surfaceEvaluator.inPreEvaluateBU_intfac(u);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::preEvaluateBV(REAL v)
|
||||
{
|
||||
surfaceEvaluator.inPreEvaluateBV_intfac(v);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* tmeshvert - evaluate a point on a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::tmeshvert( TrimVertex *t )
|
||||
{
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
const long nuid = t->nuid;
|
||||
#endif
|
||||
const REAL u = t->param[0];
|
||||
const REAL v = t->param[1];
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 0;
|
||||
mesh[meshindex][3] = nuid;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
}
|
||||
#else
|
||||
|
||||
surfaceEvaluator.evalcoord2f( 0, u, v );
|
||||
//for uninitial memory read surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
//the same as tmeshvert(trimvertex), for efficiency purpose
|
||||
void
|
||||
Backend::tmeshvert( REAL u, REAL v )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
const long nuid = 0;
|
||||
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 0;
|
||||
mesh[meshindex][3] = nuid;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
}
|
||||
#else
|
||||
|
||||
surfaceEvaluator.evalcoord2f( 0, u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* tmeshvert - evaluate a grid point of a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::tmeshvert( GridVertex *g )
|
||||
{
|
||||
const long u = g->gparam[0];
|
||||
const long v = g->gparam[1];
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 1;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
}
|
||||
#else
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* swaptmesh - perform a swap of the triangle mesh pointers
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::swaptmesh( void )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( wireframetris ) {
|
||||
meshindex = 1 - meshindex;
|
||||
} else {
|
||||
surfaceEvaluator.swaptmesh();
|
||||
}
|
||||
#else
|
||||
surfaceEvaluator.swaptmesh();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endtmesh - postamble to triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endtmesh( void )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( ! wireframetris )
|
||||
surfaceEvaluator.endtmesh();
|
||||
#else
|
||||
surfaceEvaluator.endtmesh();
|
||||
/* surfaceEvaluator.polymode( N_MESHFILL );*/
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnoutline - preamble to outlined rendering
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgnoutline( void )
|
||||
{
|
||||
surfaceEvaluator.bgnline();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* linevert - evaluate a point on an outlined contour
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::linevert( TrimVertex *t )
|
||||
{
|
||||
surfaceEvaluator.evalcoord2f( t->nuid, t->param[0], t->param[1] );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* linevert - evaluate a grid point of an outlined contour
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::linevert( GridVertex *g )
|
||||
{
|
||||
surfaceEvaluator.evalpoint2i( g->gparam[0], g->gparam[1] );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endoutline - postamble to outlined rendering
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endoutline( void )
|
||||
{
|
||||
surfaceEvaluator.endline();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* triangle - output a triangle
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::triangle( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
||||
{
|
||||
/* bgntmesh( "spittriangle" );*/
|
||||
bgntfan();
|
||||
tmeshvert( a );
|
||||
tmeshvert( b );
|
||||
tmeshvert( c );
|
||||
endtfan();
|
||||
/* endtmesh();*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgncurv( void )
|
||||
{
|
||||
curveEvaluator.bgnmap1f( 0 );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::segment( REAL ulo, REAL uhi )
|
||||
{
|
||||
curveEvaluator.domain1f( ulo, uhi );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvpts(
|
||||
long type, /* geometry, color, texture, normal */
|
||||
REAL *pts, /* control points */
|
||||
long stride, /* distance to next point */
|
||||
int order, /* parametric order */
|
||||
REAL ulo, /* lower parametric bound */
|
||||
REAL uhi ) /* upper parametric bound */
|
||||
|
||||
{
|
||||
curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
|
||||
curveEvaluator.enable( type );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvgrid( REAL u0, REAL u1, long nu )
|
||||
{
|
||||
curveEvaluator.mapgrid1f( nu, u0, u1 );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvmesh( long from, long n )
|
||||
{
|
||||
curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvpt(REAL u)
|
||||
{
|
||||
curveEvaluator.evalcoord1f( 0, u );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgnline( void )
|
||||
{
|
||||
curveEvaluator.bgnline();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endline( void )
|
||||
{
|
||||
curveEvaluator.endline();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endcurv( void )
|
||||
{
|
||||
curveEvaluator.endmap1f();
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* backend.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubackend_h_
|
||||
#define __glubackend_h_
|
||||
|
||||
#include "trimvertex.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
|
||||
class BasicCurveEvaluator;
|
||||
class BasicSurfaceEvaluator;
|
||||
|
||||
class Backend {
|
||||
private:
|
||||
BasicCurveEvaluator& curveEvaluator;
|
||||
BasicSurfaceEvaluator& surfaceEvaluator;
|
||||
public:
|
||||
Backend( BasicCurveEvaluator &c, BasicSurfaceEvaluator& e )
|
||||
: curveEvaluator(c), surfaceEvaluator(e) {}
|
||||
|
||||
/* surface backend routines */
|
||||
void bgnsurf( int, int, long );
|
||||
void patch( REAL, REAL, REAL, REAL );
|
||||
void surfpts( long, REAL *, long, long, int, int,
|
||||
REAL, REAL, REAL, REAL );
|
||||
void surfbbox( long, REAL *, REAL * );
|
||||
void surfgrid( REAL, REAL, long, REAL, REAL, long );
|
||||
void surfmesh( long, long, long, long );
|
||||
void bgntmesh( const char * );
|
||||
void endtmesh( void );
|
||||
void swaptmesh( void );
|
||||
void tmeshvert( GridTrimVertex * );
|
||||
void tmeshvert( TrimVertex * );
|
||||
void tmeshvert( GridVertex * );
|
||||
void tmeshvert( REAL u, REAL v );
|
||||
void linevert( TrimVertex * );
|
||||
void linevert( GridVertex * );
|
||||
void bgnoutline( void );
|
||||
void endoutline( void );
|
||||
void endsurf( void );
|
||||
void triangle( TrimVertex*, TrimVertex*, TrimVertex* );
|
||||
|
||||
void bgntfan();
|
||||
void endtfan();
|
||||
void bgnqstrip();
|
||||
void endqstrip();
|
||||
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
);
|
||||
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL v_right, REAL* right_val
|
||||
);
|
||||
void tmeshvertNOGE(TrimVertex *t);
|
||||
void tmeshvertNOGE_BU(TrimVertex *t);
|
||||
void tmeshvertNOGE_BV(TrimVertex *t);
|
||||
void preEvaluateBU(REAL u);
|
||||
void preEvaluateBV(REAL v);
|
||||
|
||||
|
||||
/* curve backend routines */
|
||||
void bgncurv( void );
|
||||
void segment( REAL, REAL );
|
||||
void curvpts( long, REAL *, long, int, REAL, REAL );
|
||||
void curvgrid( REAL, REAL, long );
|
||||
void curvmesh( long, long );
|
||||
void curvpt( REAL );
|
||||
void bgnline( void );
|
||||
void endline( void );
|
||||
void endcurv( void );
|
||||
private:
|
||||
#ifndef NOWIREFRAME
|
||||
int wireframetris;
|
||||
int wireframequads;
|
||||
int npts;
|
||||
REAL mesh[3][4];
|
||||
int meshindex;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __glubackend_h_ */
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basiccrveval.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "basiccrveval.h"
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::domain1f( REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "domain1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::range1f( long , REAL *, REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "range1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::enable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "enable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::disable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "disable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::bgnmap1f( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnmap1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::map1f( long, REAL, REAL, long, long, REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "map1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::mapgrid1f( long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapgrid1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::mapmesh1f( long, long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapmesh1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::evalcoord1f( long, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "evalcoord1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::endmap1f( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endmap1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::bgnline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::endline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endline\n" );
|
||||
#endif
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basiccurveeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubasiccrveval_h_
|
||||
#define __glubasiccrveval_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "displaymode.h"
|
||||
#include "cachingeval.h"
|
||||
|
||||
class BasicCurveEvaluator : public CachingEvaluator {
|
||||
public:
|
||||
virtual ~BasicCurveEvaluator() { /* silence warning*/ }
|
||||
virtual void domain1f( REAL, REAL );
|
||||
virtual void range1f( long, REAL *, REAL * );
|
||||
|
||||
virtual void enable( long );
|
||||
virtual void disable( long );
|
||||
virtual void bgnmap1f( long );
|
||||
virtual void map1f( long, REAL, REAL, long, long, REAL * );
|
||||
virtual void mapgrid1f( long, REAL, REAL );
|
||||
virtual void mapmesh1f( long, long, long );
|
||||
virtual void evalcoord1f( long, REAL );
|
||||
virtual void endmap1f( void );
|
||||
|
||||
virtual void bgnline( void );
|
||||
virtual void endline( void );
|
||||
};
|
||||
|
||||
#endif /* __glubasiccrveval_h_ */
|
|
@ -1,232 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basicsurfaceevaluator.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "basicsurfeval.h"
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#pragma warning 726 10
|
||||
#endif
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::domain2f( REAL, REAL, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "domain2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::polymode( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "polymode\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::range2f( long type, REAL *from, REAL *to )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "range2f type %ld, from (%g,%g), to (%g,%g)\n",
|
||||
type, from[0], from[1], to[0], to[1] );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::enable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "enable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::disable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "disable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnmap2f( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnmap2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endmap2f( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endmap2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long,
|
||||
REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "map2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::mapgrid2f( long, REAL, REAL, long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapgrid2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::mapmesh2f( long, long, long, long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapmesh2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::evalcoord2f( long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "evalcoord2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::evalpoint2i( long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "evalpoint2i\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnclosedline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnclosedline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endclosedline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endclosedline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgntfan( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgntfan\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endtfan( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgntmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgntmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::swaptmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "swaptmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endtmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endtmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnqstrip( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnqstrip\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endqstrip( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endqstrip\n" );
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basicsurfeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubasicsurfeval_h_
|
||||
#define __glubasicsurfeval_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "displaymode.h"
|
||||
#include "cachingeval.h"
|
||||
|
||||
class BasicSurfaceEvaluator : public CachingEvaluator {
|
||||
public:
|
||||
virtual ~BasicSurfaceEvaluator() { /* silence warning*/ }
|
||||
virtual void range2f( long, REAL *, REAL * );
|
||||
virtual void domain2f( REAL, REAL, REAL, REAL );
|
||||
|
||||
virtual void enable( long );
|
||||
virtual void disable( long );
|
||||
virtual void bgnmap2f( long );
|
||||
virtual void map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long,
|
||||
REAL * );
|
||||
virtual void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
|
||||
virtual void mapmesh2f( long, long, long, long, long );
|
||||
virtual void evalcoord2f( long, REAL, REAL );
|
||||
virtual void evalpoint2i( long, long );
|
||||
virtual void endmap2f( void );
|
||||
|
||||
virtual void polymode( long );
|
||||
virtual void bgnline( void );
|
||||
virtual void endline( void );
|
||||
virtual void bgnclosedline( void );
|
||||
virtual void endclosedline( void );
|
||||
virtual void bgntmesh( void );
|
||||
virtual void swaptmesh( void );
|
||||
virtual void endtmesh( void );
|
||||
virtual void bgnqstrip( void );
|
||||
virtual void endqstrip( void );
|
||||
|
||||
virtual void bgntfan( void );
|
||||
virtual void endtfan( void );
|
||||
|
||||
virtual void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
) = 0;
|
||||
|
||||
virtual void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val
|
||||
) = 0;
|
||||
virtual void inDoEvalCoord2NOGE(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inDoEvalCoord2NOGE_BU(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inDoEvalCoord2NOGE_BV(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inPreEvaluateBV_intfac(REAL v ) = 0;
|
||||
virtual void inPreEvaluateBU_intfac(REAL u ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __glubasicsurfeval_h_ */
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bezierarc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubezierarc_h
|
||||
#define __glubezierarc_h
|
||||
|
||||
#include "myassert.h"
|
||||
|
||||
class Mapdesc;
|
||||
|
||||
struct BezierArc : public PooledObj { /* a bezier arc */
|
||||
REAL * cpts; /* control points of arc */
|
||||
int order; /* order of arc */
|
||||
int stride; /* REAL distance between points */
|
||||
long type; /* curve type */
|
||||
Mapdesc * mapdesc;
|
||||
};
|
||||
|
||||
#endif /* __glubezierarc_h */
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bin.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "bin.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Constructor and destructor
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Bin::Bin()
|
||||
{
|
||||
head = NULL;
|
||||
}
|
||||
|
||||
Bin::~Bin()
|
||||
{
|
||||
assert( head == NULL);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* remove_this_arc - remove given Arc_ptr from bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::remove_this_arc( Arc_ptr arc )
|
||||
{
|
||||
Arc_ptr *j;
|
||||
for( j = &(head); (*j != 0) && (*j != arc); j = &((*j)->link) );
|
||||
|
||||
if( *j != 0 ) {
|
||||
if( *j == current )
|
||||
current = (*j)->link;
|
||||
*j = (*j)->link;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* numarcs - count number of arcs in bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Bin::numarcs()
|
||||
{
|
||||
long count = 0;
|
||||
for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* adopt - place an orphaned arcs into their new parents bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::adopt()
|
||||
{
|
||||
markall();
|
||||
|
||||
Arc_ptr orphan;
|
||||
while( (orphan = removearc()) != NULL ) {
|
||||
for( Arc_ptr parent = orphan->next; parent != orphan; parent = parent->next ) {
|
||||
if (! parent->ismarked() ) {
|
||||
orphan->link = parent->link;
|
||||
parent->link = orphan;
|
||||
orphan->clearmark();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* show - print out descriptions of the arcs in the bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::show( char *name )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "%s\n", name );
|
||||
for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
||||
jarc->show( );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* markall - mark all arcs with an identifying tag
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::markall()
|
||||
{
|
||||
for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() )
|
||||
jarc->setmark();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* listBezier - print out all arcs that are untessellated border arcs
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::listBezier( void )
|
||||
{
|
||||
for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() ) {
|
||||
if( jarc->isbezier( ) ) {
|
||||
assert( jarc->pwlArc->npts == 2 );
|
||||
#ifndef NDEBUG
|
||||
TrimVertex *pts = jarc->pwlArc->pts;
|
||||
REAL s1 = pts[0].param[0];
|
||||
REAL t1 = pts[0].param[1];
|
||||
REAL s2 = pts[1].param[0];
|
||||
REAL t2 = pts[1].param[1];
|
||||
_glu_dprintf( "arc (%g,%g) (%g,%g)\n", s1, t1, s2, t2 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bin.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubin_h_
|
||||
#define __glubin_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Bin
|
||||
{ /* a linked list of jordan arcs */
|
||||
private:
|
||||
Arc_ptr head;/*first arc on list */
|
||||
Arc_ptr current; /* current arc on list */
|
||||
public:
|
||||
Bin();
|
||||
~Bin();
|
||||
inline Arc_ptr firstarc( void );
|
||||
inline Arc_ptr nextarc( void );
|
||||
inline Arc_ptr removearc( void );
|
||||
inline int isnonempty( void ) { return (head ? 1 : 0); }
|
||||
inline void addarc( Arc_ptr );
|
||||
void remove_this_arc( Arc_ptr );
|
||||
int numarcs( void );
|
||||
void adopt( void );
|
||||
void markall( void );
|
||||
void show( char * );
|
||||
void listBezier( void );
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Bin::addarc - add an Arc_ptr to head of linked list of Arc_ptr
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void
|
||||
Bin::addarc( Arc_ptr jarc )
|
||||
{
|
||||
jarc->link = head;
|
||||
head = jarc;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Bin::removearc - remove first Arc_ptr from bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::removearc( void )
|
||||
{
|
||||
Arc_ptr jarc = head;
|
||||
|
||||
if( jarc ) head = jarc->link;
|
||||
return jarc;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* BinIter::nextarc - return current arc in bin and advance pointer to next arc
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::nextarc( void )
|
||||
{
|
||||
Arc_ptr jarc = current;
|
||||
|
||||
#ifdef DEBUG
|
||||
assert( jarc->check() != 0 );
|
||||
#endif
|
||||
|
||||
if( jarc ) current = jarc->link;
|
||||
return jarc;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* BinIter::firstarc - set current arc to first arc of bin advance to next arc
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::firstarc( void )
|
||||
{
|
||||
current = head;
|
||||
return nextarc( );
|
||||
}
|
||||
|
||||
#endif /* __glubin_h_ */
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bufpool.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool - allocate a new pool of buffers
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
Pool::Pool( int _buffersize, int initpoolsize, const char *n )
|
||||
{
|
||||
if((unsigned)_buffersize < sizeof(Buffer))
|
||||
buffersize = sizeof(Buffer);
|
||||
else
|
||||
buffersize = _buffersize;
|
||||
initsize = initpoolsize * buffersize;
|
||||
nextsize = initsize;
|
||||
name = n;
|
||||
magic = is_allocated;
|
||||
nextblock = 0;
|
||||
curblock = 0;
|
||||
freelist = 0;
|
||||
nextfree = 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ~Pool - free a pool of buffers and the pool itself
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Pool::~Pool( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
while( nextblock ) {
|
||||
delete [] blocklist[--nextblock];
|
||||
blocklist[nextblock] = 0;
|
||||
}
|
||||
magic = is_free;
|
||||
}
|
||||
|
||||
|
||||
void Pool::grow( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
curblock = new char[nextsize];
|
||||
blocklist[nextblock++] = curblock;
|
||||
nextfree = nextsize;
|
||||
nextsize *= 2;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::clear - free buffers associated with pool but keep pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Pool::clear( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
while( nextblock ) {
|
||||
delete [] blocklist[--nextblock];
|
||||
blocklist[nextblock] = 0;
|
||||
}
|
||||
curblock = 0;
|
||||
freelist = 0;
|
||||
nextfree = 0;
|
||||
if( nextsize > initsize )
|
||||
nextsize /= 2;
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bufpool.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubufpool_h_
|
||||
#define __glubufpool_h_
|
||||
|
||||
#include "gluos.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdlib.h"
|
||||
|
||||
#define NBLOCKS 32
|
||||
|
||||
class Buffer {
|
||||
friend class Pool;
|
||||
Buffer * next; /* next buffer on free list */
|
||||
};
|
||||
|
||||
class Pool {
|
||||
public:
|
||||
Pool( int, int, const char * );
|
||||
~Pool( void );
|
||||
inline void* new_buffer( void );
|
||||
inline void free_buffer( void * );
|
||||
void clear( void );
|
||||
|
||||
private:
|
||||
void grow( void );
|
||||
|
||||
protected:
|
||||
Buffer *freelist; /* linked list of free buffers */
|
||||
char *blocklist[NBLOCKS]; /* blocks of malloced memory */
|
||||
int nextblock; /* next free block index */
|
||||
char *curblock; /* last malloced block */
|
||||
int buffersize; /* bytes per buffer */
|
||||
int nextsize; /* size of next block of memory */
|
||||
int nextfree; /* byte offset past next free buffer */
|
||||
int initsize;
|
||||
enum Magic { is_allocated = 0xf3a1, is_free = 0xf1a2 };
|
||||
const char *name; /* name of the pool */
|
||||
Magic magic; /* marker for valid pool */
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::free_buffer - return a buffer to a pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void
|
||||
Pool::free_buffer( void *b )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
/* add buffer to singly connected free list */
|
||||
|
||||
((Buffer *) b)->next = freelist;
|
||||
freelist = (Buffer *) b;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::new_buffer - allocate a buffer from a pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void *
|
||||
Pool::new_buffer( void )
|
||||
{
|
||||
void *buffer;
|
||||
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
/* find free buffer */
|
||||
|
||||
if( freelist ) {
|
||||
buffer = (void *) freelist;
|
||||
freelist = freelist->next;
|
||||
} else {
|
||||
if( ! nextfree )
|
||||
grow( );
|
||||
nextfree -= buffersize;;
|
||||
buffer = (void *) (curblock + nextfree);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
class PooledObj {
|
||||
public:
|
||||
inline void * operator new( size_t, Pool & );
|
||||
inline void * operator new( size_t, void *);
|
||||
inline void * operator new( size_t s)
|
||||
{ return ::new char[s]; }
|
||||
inline void operator delete( void * ) { assert( 0 ); }
|
||||
inline void operator delete( void *, Pool & ) { assert( 0 ); }
|
||||
inline void deleteMe( Pool & );
|
||||
};
|
||||
|
||||
inline void *
|
||||
PooledObj::operator new( size_t, Pool& pool )
|
||||
{
|
||||
return pool.new_buffer();
|
||||
}
|
||||
|
||||
inline void
|
||||
PooledObj::deleteMe( Pool& pool )
|
||||
{
|
||||
pool.free_buffer( (void *) this );
|
||||
}
|
||||
|
||||
#endif /* __glubufpool_h_ */
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* cachingeval.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cachingeval.h"
|
||||
|
||||
int
|
||||
CachingEvaluator::canRecord( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CachingEvaluator::canPlayAndRecord( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CachingEvaluator::createHandle( int )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::beginOutput( ServiceMode, int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::endOutput( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::discardRecording( int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::playRecording( int )
|
||||
{
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* 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
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* cachingeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glucachingval_h_
|
||||
#define __glucachingval_h_
|
||||
|
||||
class CachingEvaluator {
|
||||
public:
|
||||
virtual ~CachingEvaluator() { /* silence warning*/ }
|
||||
enum ServiceMode { play, record, playAndRecord };
|
||||
virtual int canRecord( void );
|
||||
virtual int canPlayAndRecord( void );
|
||||
virtual int createHandle( int handle );
|
||||
virtual void beginOutput( ServiceMode, int handle );
|
||||
virtual void endOutput( void );
|
||||
virtual void discardRecording( int handle );
|
||||
virtual void playRecording( int handle );
|
||||
};
|
||||
#endif /* __glucachingval_h_ */
|
|
@ -1,565 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ccw.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "subdivider.h"
|
||||
#include "types.h"
|
||||
#include "arc.h"
|
||||
#include "trimvertex.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
inline int
|
||||
Subdivider::bbox( TrimVertex *a, TrimVertex *b, TrimVertex *c, int p )
|
||||
{
|
||||
return bbox( a->param[p], b->param[p], c->param[p],
|
||||
a->param[1-p], b->param[1-p], c->param[1-p] );
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_sr( Arc_ptr j1, Arc_ptr j2 ) // dir = 1
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 0 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (0 == v1->param[0])
|
||||
if( v1->param[0] == v1next->param[0] && v2->param[0] == v2next->param[0] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[0] < v2->param[0] || v1next->param[0] < v1->param[0] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[1] < v2->param[1] )
|
||||
return 0;
|
||||
else if( v1->param[1] > v2->param[1] )
|
||||
return 1;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[0] < v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case a\n" );
|
||||
#endif
|
||||
assert( v1->param[0] <= v1next->param[0] );
|
||||
assert( v2->param[0] <= v1next->param[0] );
|
||||
switch( bbox( v2, v2next, v1next, 1 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
v1 = v1next--;
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else if( v1next->param[0] > v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case b\n" );
|
||||
#endif
|
||||
assert( v1->param[0] <= v2next->param[0] );
|
||||
assert( v2->param[0] <= v2next->param[0] );
|
||||
switch( bbox( v1, v1next, v2next, 1 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case ab\n" );
|
||||
#endif
|
||||
if( v1next->param[1] < v2next->param[1] )
|
||||
return 0;
|
||||
else if( v1next->param[1] > v2next->param[1] )
|
||||
return 1;
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_sl( Arc_ptr j1, Arc_ptr j2 ) // dir = 0
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 0 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (0 == v1->param[0])
|
||||
if( v1->param[0] == v1next->param[0] && v2->param[0] == v2next->param[0] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[0] > v2->param[0] || v1next->param[0] > v1->param[0] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[1] < v2->param[1] )
|
||||
return 1;
|
||||
else if( v1->param[1] > v2->param[1] )
|
||||
return 0;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[0] > v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case c\n" );
|
||||
#endif
|
||||
assert( v1->param[0] >= v1next->param[0] );
|
||||
assert( v2->param[0] >= v1next->param[0] );
|
||||
switch( bbox( v2next, v2, v1next, 1 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v1 = v1next--;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else if( v1next->param[0] < v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case d\n" );
|
||||
#endif
|
||||
assert( v1->param[0] >= v2next->param[0] );
|
||||
assert( v2->param[0] >= v2next->param[0] );
|
||||
switch( bbox( v1next, v1, v2next, 1 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "case cd\n" );
|
||||
#endif
|
||||
if( v1next->param[1] < v2next->param[1] )
|
||||
return 1;
|
||||
else if( v1next->param[1] > v2next->param[1] )
|
||||
return 0;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_tr( Arc_ptr j1, Arc_ptr j2 ) // dir = 1
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 1 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (1 == v1->param[1])
|
||||
if( v1->param[1] == v1next->param[1] && v2->param[1] == v2next->param[1] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[1] < v2->param[1] || v1next->param[1] < v1->param[1] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[0] < v2->param[0] )
|
||||
return 1;
|
||||
else if( v1->param[0] > v2->param[0] )
|
||||
return 0;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[1] < v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case a\n" );
|
||||
#endif
|
||||
assert( v1->param[1] <= v1next->param[1] );
|
||||
assert( v2->param[1] <= v1next->param[1] );
|
||||
switch( bbox( v2, v2next, v1next, 0 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
v1 = v1next--;
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else if( v1next->param[1] > v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case b\n" );
|
||||
#endif
|
||||
assert( v1->param[1] <= v2next->param[1] );
|
||||
assert( v2->param[1] <= v2next->param[1] );
|
||||
switch( bbox( v1, v1next, v2next, 0 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "case ab\n" );
|
||||
#endif
|
||||
if( v1next->param[0] < v2next->param[0] )
|
||||
return 1;
|
||||
else if( v1next->param[0] > v2next->param[0] )
|
||||
return 0;
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_tl( Arc_ptr j1, Arc_ptr j2 )
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 1 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (1 == v1->param[1])
|
||||
if( v1->param[1] == v1next->param[1] && v2->param[1] == v2next->param[1] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[1] > v2->param[1] || v1next->param[1] > v1->param[1] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[0] < v2->param[0] )
|
||||
return 0;
|
||||
else if( v1->param[0] > v2->param[0] )
|
||||
return 1;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[1] > v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case c\n" );
|
||||
#endif
|
||||
assert( v1->param[1] >= v1next->param[1] );
|
||||
assert( v2->param[1] >= v1next->param[1] );
|
||||
switch( bbox( v2next, v2, v1next, 0 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v1 = v1next--;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else if( v1next->param[1] < v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case d\n" );
|
||||
assert( v1->param[1] >= v2next->param[1] );
|
||||
assert( v2->param[1] >= v2next->param[1] );
|
||||
#endif
|
||||
switch( bbox( v1next, v1, v2next, 0 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "case cd\n" );
|
||||
#endif
|
||||
if( v1next->param[0] < v2next->param[0] )
|
||||
return 0;
|
||||
else if( v1next->param[0] > v2next->param[0] )
|
||||
return 1;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
int
|
||||
Subdivider::bbox( register REAL sa, register REAL sb, register REAL sc,
|
||||
register REAL ta, register REAL tb, register REAL tc )
|
||||
#else
|
||||
int
|
||||
Subdivider::bbox( register REAL sa, register REAL sb, register REAL sc,
|
||||
register REAL , register REAL , register REAL )
|
||||
#endif
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert( tc >= ta );
|
||||
assert( tc <= tb );
|
||||
#endif
|
||||
|
||||
if( sa < sb ) {
|
||||
if( sc <= sa ) {
|
||||
return -1;
|
||||
} else if( sb <= sc ) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if( sa > sb ) {
|
||||
if( sc >= sa ) {
|
||||
return 1;
|
||||
} else if( sb >= sc ) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if( sc > sa ) {
|
||||
return 1;
|
||||
} else if( sb > sc ) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ccw - determine how three points are oriented by computing their
|
||||
* determinant.
|
||||
* Return 1 if the vertices are ccw oriented,
|
||||
* 0 if they are cw oriented, or
|
||||
* -1 if the computation is ill-conditioned.
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::ccw( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
||||
{
|
||||
REAL d = det3( a, b, c );
|
||||
if( glu_abs(d) < 0.0001 ) return -1;
|
||||
return (d < 0.0) ? 0 : 1;
|
||||
}
|
|
@ -1,440 +0,0 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* coveandtiler.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "coveandtiler.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "uarray.h"
|
||||
#include "backend.h"
|
||||
|
||||
|
||||
const int CoveAndTiler::MAXSTRIPSIZE = 1000;
|
||||
|
||||
CoveAndTiler::CoveAndTiler( Backend& b )
|
||||
: backend( b )
|
||||
{ }
|
||||
|
||||
CoveAndTiler::~CoveAndTiler( void )
|
||||
{ }
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( GridVertex &gv )
|
||||
{
|
||||
backend.tmeshvert( &gv );
|
||||
}
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( TrimVertex *tv )
|
||||
{
|
||||
backend.tmeshvert( tv );
|
||||
}
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( GridTrimVertex& g )
|
||||
{
|
||||
backend.tmeshvert( &g );
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveAndTile( void )
|
||||
{
|
||||
long ustart = (top.ustart >= bot.ustart) ? top.ustart : bot.ustart;
|
||||
long uend = (top.uend <= bot.uend) ? top.uend : bot.uend;
|
||||
if( ustart <= uend ) {
|
||||
tile( bot.vindex, ustart, uend );
|
||||
if( top.ustart >= bot.ustart )
|
||||
coveUpperLeft();
|
||||
else
|
||||
coveLowerLeft();
|
||||
|
||||
if( top.uend <= bot.uend )
|
||||
coveUpperRight();
|
||||
else
|
||||
coveLowerRight();
|
||||
} else {
|
||||
TrimVertex blv, tlv, *bl, *tl;
|
||||
GridTrimVertex bllv, tllv;
|
||||
TrimVertex *lf = left.first();
|
||||
TrimVertex *ll = left.last();
|
||||
if( lf->param[0] >= ll->param[0] ) {
|
||||
blv.param[0] = lf->param[0];
|
||||
blv.param[1] = ll->param[1];
|
||||
blv.nuid = 0; // XXX
|
||||
assert( blv.param[1] == bot.vval );
|
||||
bl = &blv;
|
||||
tl = lf;
|
||||
tllv.set( lf );
|
||||
if( ll->param[0] > uarray.uarray[top.ustart-1] ) {
|
||||
bllv.set( ll );
|
||||
assert( ll->param[0] <= uarray.uarray[bot.ustart] );
|
||||
} else {
|
||||
bllv.set( top.ustart-1, bot.vindex );
|
||||
}
|
||||
coveUpperLeftNoGrid( bl );
|
||||
} else {
|
||||
tlv.param[0] = ll->param[0];
|
||||
tlv.param[1] = lf->param[1];
|
||||
tlv.nuid = 0; // XXX
|
||||
assert( tlv.param[1] == top.vval );
|
||||
tl = &tlv;
|
||||
bl = ll;
|
||||
bllv.set( ll );
|
||||
if( lf->param[0] > uarray.uarray[bot.ustart-1] ) {
|
||||
assert( lf->param[0] <= uarray.uarray[bot.ustart] );
|
||||
tllv.set( lf );
|
||||
} else {
|
||||
tllv.set( bot.ustart-1, top.vindex );
|
||||
}
|
||||
coveLowerLeftNoGrid( tl );
|
||||
}
|
||||
|
||||
TrimVertex brv, trv, *br, *tr;
|
||||
GridTrimVertex brrv, trrv;
|
||||
TrimVertex *rf = right.first();
|
||||
TrimVertex *rl = right.last();
|
||||
|
||||
if( rf->param[0] <= rl->param[0] ) {
|
||||
brv.param[0] = rf->param[0];
|
||||
brv.param[1] = rl->param[1];
|
||||
brv.nuid = 0; // XXX
|
||||
assert( brv.param[1] == bot.vval );
|
||||
br = &brv;
|
||||
tr = rf;
|
||||
trrv.set( rf );
|
||||
if( rl->param[0] < uarray.uarray[top.uend+1] ) {
|
||||
assert( rl->param[0] >= uarray.uarray[top.uend] );
|
||||
brrv.set( rl );
|
||||
} else {
|
||||
brrv.set( top.uend+1, bot.vindex );
|
||||
}
|
||||
coveUpperRightNoGrid( br );
|
||||
} else {
|
||||
trv.param[0] = rl->param[0];
|
||||
trv.param[1] = rf->param[1];
|
||||
trv.nuid = 0; // XXX
|
||||
assert( trv.param[1] == top.vval );
|
||||
tr = &trv;
|
||||
br = rl;
|
||||
brrv.set( rl );
|
||||
if( rf->param[0] < uarray.uarray[bot.uend+1] ) {
|
||||
assert( rf->param[0] >= uarray.uarray[bot.uend] );
|
||||
trrv.set( rf );
|
||||
} else {
|
||||
trrv.set( bot.uend+1, top.vindex );
|
||||
}
|
||||
coveLowerRightNoGrid( tr );
|
||||
}
|
||||
|
||||
backend.bgntmesh( "doit" );
|
||||
output(trrv);
|
||||
output(tllv);
|
||||
output( tr );
|
||||
output( tl );
|
||||
output( br );
|
||||
output( bl );
|
||||
output(brrv);
|
||||
output(bllv);
|
||||
backend.endtmesh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::tile( long vindex, long ustart, long uend )
|
||||
{
|
||||
long numsteps = uend - ustart;
|
||||
|
||||
if( numsteps == 0 ) return;
|
||||
|
||||
if( numsteps > MAXSTRIPSIZE ) {
|
||||
long umid = ustart + (uend - ustart) / 2;
|
||||
tile( vindex, ustart, umid );
|
||||
tile( vindex, umid, uend );
|
||||
} else {
|
||||
backend.surfmesh( ustart, vindex-1, numsteps, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperRight( void )
|
||||
{
|
||||
GridVertex tgv( top.uend, top.vindex );
|
||||
GridVertex gv( top.uend, bot.vindex );
|
||||
|
||||
right.first();
|
||||
backend.bgntmesh( "coveUpperRight" );
|
||||
output( right.next() );
|
||||
output( tgv );
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
coveUR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperRightNoGrid( TrimVertex* br )
|
||||
{
|
||||
backend.bgntmesh( "coveUpperRight" );
|
||||
output( right.first() );
|
||||
output( right.next() );
|
||||
backend.swaptmesh();
|
||||
output( br );
|
||||
coveUR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUR( )
|
||||
{
|
||||
GridVertex gv( top.uend, bot.vindex );
|
||||
TrimVertex *vert = right.next();
|
||||
if( vert == NULL ) return;
|
||||
|
||||
assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.nextu() >= bot.uend ) {
|
||||
for( ; vert; vert = right.next() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
vert = right.next();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
if( gv.nextu() == bot.uend ) {
|
||||
for( ; vert; vert = right.next() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperLeft( void )
|
||||
{
|
||||
GridVertex tgv( top.ustart, top.vindex );
|
||||
GridVertex gv( top.ustart, bot.vindex );
|
||||
|
||||
left.first();
|
||||
backend.bgntmesh( "coveUpperLeft" );
|
||||
output( tgv );
|
||||
output( left.next() );
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
coveUL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperLeftNoGrid( TrimVertex* bl )
|
||||
{
|
||||
backend.bgntmesh( "coveUpperLeftNoGrid" );
|
||||
output( left.first() );
|
||||
output( left.next() );
|
||||
output( bl );
|
||||
backend.swaptmesh();
|
||||
coveUL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUL()
|
||||
{
|
||||
GridVertex gv( top.ustart, bot.vindex );
|
||||
TrimVertex *vert = left.next();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.prevu() <= bot.ustart ) {
|
||||
for( ; vert; vert = left.next() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] > uarray.uarray[gv.gparam[0]] ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
vert = left.next();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
if( gv.prevu() == bot.ustart ) {
|
||||
for( ; vert; vert = left.next() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerLeft( void )
|
||||
{
|
||||
GridVertex bgv( bot.ustart, bot.vindex );
|
||||
GridVertex gv( bot.ustart, top.vindex );
|
||||
|
||||
left.last();
|
||||
backend.bgntmesh( "coveLowerLeft" );
|
||||
output( left.prev() );
|
||||
output( bgv );
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
coveLL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerLeftNoGrid( TrimVertex* tl )
|
||||
{
|
||||
backend.bgntmesh( "coveLowerLeft" );
|
||||
output( left.last() );
|
||||
output( left.prev() );
|
||||
backend.swaptmesh();
|
||||
output( tl );
|
||||
coveLL( );
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLL()
|
||||
{
|
||||
GridVertex gv( bot.ustart, top.vindex );
|
||||
TrimVertex *vert = left.prev();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.prevu() <= top.ustart ) {
|
||||
for( ; vert; vert = left.prev() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] > uarray.uarray[gv.gparam[0]] ){
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
vert = left.prev();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
if( gv.prevu() == top.ustart ) {
|
||||
for( ; vert; vert = left.prev() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerRight( void )
|
||||
{
|
||||
GridVertex bgv( bot.uend, bot.vindex );
|
||||
GridVertex gv( bot.uend, top.vindex );
|
||||
|
||||
right.last();
|
||||
backend.bgntmesh( "coveLowerRight" );
|
||||
output( bgv );
|
||||
output( right.prev() );
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
coveLR();
|
||||
backend.endtmesh( );
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerRightNoGrid( TrimVertex* tr )
|
||||
{
|
||||
backend.bgntmesh( "coveLowerRIght" );
|
||||
output( right.last() );
|
||||
output( right.prev() );
|
||||
output( tr );
|
||||
backend.swaptmesh();
|
||||
coveLR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLR( )
|
||||
{
|
||||
GridVertex gv( bot.uend, top.vindex );
|
||||
TrimVertex *vert = right.prev();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.nextu() >= top.uend ) {
|
||||
for( ; vert; vert = right.prev() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
vert = right.prev();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
if( gv.nextu() == top.uend ) {
|
||||
for( ; vert; vert = right.prev() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue