opennurbs_gl.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2011 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Assoicates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00018 //                              
00019 //  Definitions of ON_GL() functions that demonstrate how to
00020 //  use GL to display OpenNURBS objects.                        
00021 //                              
00023 
00024 #include "opennurbs.h"
00025 
00026 #if defined(ON_COMPILER_MSC)
00027 
00028 // Tested compilers:
00029 //   Microsoft Developer Studio 6.0
00030 //   Microsoft Visual Studio 2005
00031 //   Support for other Windows compilers is not available.
00032 
00033 // Windows Open GL files require windows.h to be included before the
00034 // Open GL header files.
00035 #include <windows.h>
00036 #include <GL/gl.h>      // Open GL basic definitions
00037 #include <GL/glu.h>     // Open GL utilities (for GL NURBS stuff)
00038 
00039 #elif defined(ON_COMPILER_XCODE)
00040 
00041 // Tested compilers:
00042 //   Apple XCode 2.4.1
00043 //   Support for other Apple compilers is not available.
00044 #include <GLUT/glut.h>   // Open GL auxillary functions
00045 
00046 #else
00047 
00048 // Unsupported compiler:
00049 //   Support for other compilers is not available
00050 #include <GL/gl.h>      // Open GL basic definitions
00051 #include <GL/glu.h>     // Open GL utilities (for GL NURBS stuff)
00052 
00053 #endif
00054 
00055 
00056 #if !defined(OPENNURBS_GL_INC_)
00057 #define OPENNURBS_GL_INC_
00058 
00059 
00060 // Use ON_GL( const ON_Point, ...) to render single points.
00061 void ON_GL( 
00062       const ON_Point&
00063       );
00064 
00065 // Use ON_GL( const ON_PointCloud, ...) to render Rhino point sets.
00066 void ON_GL( 
00067       const ON_PointCloud&
00068       );
00069 
00070 // Use ON_GL( const ON_Mesh&, ...) to render OpenNURBS meshes.
00071 void ON_GL( 
00072       const ON_Mesh&
00073       );
00074 
00075 // Use ON_GL( const ON_Brep&, ...) to render OpenNURBS b-reps.
00076 void ON_GL( 
00077       const ON_Brep&,
00078       GLUnurbsObj*
00079       );
00080 
00081 // must be bracketed by calls to glBegin(GL_POINTS) / glEnd()
00082 void ON_GL(
00083       const ON_3dPoint&
00084       );
00085 
00086 void ON_GL( 
00087       const ON_Curve&,   // 
00088       GLUnurbsObj*,      // created with gluNewNurbsRenderer
00089       GLenum = 0,        // type of curve (if 0, type is automatically set)
00090       double[][4] = NULL // optional transformation applied to curve
00091       );
00092 
00093 // must be bracketed by calls to gluBeginSurface( nobj )/gluEndSurface( nobj )
00094 void ON_GL( 
00095       const ON_Surface&,   // 
00096       GLUnurbsObj*         // created with gluNewNurbsRenderer
00097       );
00098 
00099 // Use ON_GL( const ON_NurbsCurve&,...) in place of
00100 // gluNurbsCurve().  See your system's gluNurbsCurve() documentation
00101 // for details.  In particular, for 3d curves the call to 
00102 // ON_GL( const ON_NurbsCurve&, nobj,...) should appear inside
00103 // of a gluBeginCurve( nobj )/gluEndCurve( nobj ) pair.
00104 // Generally, the GL "type" should be set using the formula
00105 //   ON_NurbsCurve:IsRational()
00106 //   ? GL_MAP1_VERTEX_4 
00107 //   : GL_MAP1_VERTEX_3;
00108 void ON_GL( 
00109       const ON_NurbsCurve&, // 
00110       GLUnurbsObj*,         // created with gluNewNurbsRenderer
00111       GLenum = 0,           // type of curve (if 0, type is automatically set)
00112       int = 1,              // bPermitKnotScaling - If true, curve knots may
00113                             // be rescaled to avoid knot vectors GL cannot handle.
00114       double* = NULL,       // knot_scale[2] - If not NULL and bPermitKnotScaling,
00115                             // the scaling applied to the knot vector is
00116                             // returned here.
00117       double[][4] = NULL    // optional transformation applied to curve
00118       );
00119 
00120 void ON_GL( // low level NURBS curve renderer
00121       int, int, int, int, // dim, is_rat, cv_count, order
00122       const double*,      // knot_vector[]
00123       int,                // cv_stride
00124       const double*,      // cv
00125       GLUnurbsObj*,       // created with gluNewNurbsRenderer
00126       GLenum = 0,         // type of curve (if 0, type is automatically set)
00127       int = 1,            // bPermitKnotScaling - If true, curve knots may
00128                           // be rescaled to avoid knot vectors GL cannot handle.
00129       double* = NULL,     // knot_scale[2] - If not NULL and bPermitKnotScaling,
00130                           // the scaling applied to the knot vector is
00131                           // returned here.
00132       double[][4] = NULL  // optional transformation applied to curve
00133       );
00134 
00135 
00136 // Use ON_GL( const ON_NurbsSurface&,...) in place of
00137 // gluNurbsSurface().  See your system's gluNurbsSurface() documentation
00138 // for details.  In particular, the call to 
00139 // ON_GL( const ON_NurbsSurface&, nobj, ...) should appear inside
00140 // of a gluBeginSurface( nobj )/gluEndSurface( nobj ) pair.
00141 // Generally, the GL "type" should be set using the formula
00142 //   ON_NurbsSurface:IsRational()
00143 //   ? GL_MAP2_VERTEX_4 
00144 //   : GL_MAP2_VERTEX_3;
00145 void ON_GL( 
00146       const ON_NurbsSurface&, // 
00147       GLUnurbsObj*,              // created with gluNewNurbsRenderer
00148       GLenum = 0,                // type of surface 
00149                                  // (if 0, type is automatically set)
00150       int = 1,           // bPermitKnotScaling - If true, surface knots may
00151                          // be rescaled to avoid knot vectors GL cannot handle.
00152       double* = NULL,    // knot_scale0[2] - If not NULL and bPermitKnotScaling,
00153                          // the scaleing applied to the first parameter is
00154                          // returned here.
00155       double* = NULL     // knot_scale0[2] - If not NULL and bPermitKnotScaling,
00156                          // the scaleing applied to the second parameter is
00157                          // returned here.
00158       );
00159 
00160 
00161 // Use ON_GL( const ON_BrepFace&, nobj ) to render
00162 // the trimmed NURBS surface that defines a ON_Brep face's geometry.
00163 // The call to ON_GL( const ON_BrepFace&, nobj ) should
00164 // appear inside of a gluBeginSurface( nobj )/gluEndSurface( nobj )
00165 // pair.
00166 void ON_GL( 
00167       const ON_BrepFace&, // 
00168       GLUnurbsObj*       // created with gluNewNurbsRenderer
00169       );
00170 
00171 // Use ON_GL( const ON_Color ...) to set GL color to OpenNURBS color
00172 void ON_GL( const ON_Color&,
00173               GLfloat[4] 
00174               );
00175 void ON_GL( const ON_Color&,
00176               double, // alpha
00177               GLfloat[4] 
00178               );
00179 
00180 // Use ON_GL( const ON_Material ...) to set GL material to OpenNURBS material
00181 void ON_GL( 
00182       const ON_Material&
00183       );
00184 
00185 void ON_GL( 
00186       const ON_Material* // pass NULL to get OpenNURBS's default material
00187       );
00188 
00189 // Use ON_GL( const ON_Light, ...) to add OpenNURBS spotlights to
00190 // GL lighting model
00191 void ON_GL( 
00192       const ON_Light*, // pass NULL to disable the light
00193       GLenum                  // GL_LIGHTi where 0 <= i <= GL_MAX_LIGHTS
00194                               // See glLight*() documentation for details
00195       );
00196 void ON_GL( 
00197       const ON_Light&,
00198       GLenum                  // GL_LIGHTi where 0 <= i <= GL_MAX_LIGHTS
00199                               // See glLight*() documentation for details
00200       );
00201 
00203 // Use ON_GL( ON_Viewport& ... ) to set the GL projections to match
00204 // those used in the OpenNURBS viewport.
00205 
00207 //
00208 // Use ON_GL( ON_Viewport&, in, int, int, int ) to specify the size of the
00209 // GL window and loads the GL projection matrix (camera to clip 
00210 // transformation). If the aspect ratio of the GL window and 
00211 // ON_Viewport's frustum do not match, the viewport's frustum is 
00212 // adjusted to get things back to 1:1.  
00213 //
00214 // For systems where the upper left corner of a window has 
00215 // coordinates (0,0) use:
00216 //   port_left   = 0
00217 //   port_right  = width-1
00218 //   port_bottom = height-1
00219 //   port_top    = 0
00220 void ON_GL( ON_Viewport&,
00221             int, int, // port_left, port_right (port_left != port_right)
00222             int, int  // port_bottom, port_top (port_bottom != port_top)
00223             );
00224 
00226 //
00227 // Use ON_GL( ON_Viewport& ) to load the GL model view matrix (world to 
00228 // camera transformation).
00229 void ON_GL( const ON_Viewport& );
00230 
00231 // Use ON_GL( order, cv_count, knot, bPermitScaling, glknot )
00232 // to create knot vectors suitable for GL NURBS rendering.
00233 void ON_GL( 
00234           const int,     // order, ON_NurbsCurve... order
00235           const int,     // cv_count, ON_NurbsCurve... cv count
00236           const double*, // knot, ON_NurbsCurve... knot vector
00237           GLfloat*,      // glknot[] - GL knot vector
00238           int = 0,       // bPermitScaling - true if re-scaling is allowed
00239           double* = NULL // scale[2] - If not NULL and bPermitScaling is true,
00240                          // then the scaling parameters are returned here.
00241                          // ( glknot = (knot = scale[0])*scale[1] )
00242           );
00243 
00244 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:01