QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_gl.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
17//
18// Definitions of ON_GL() functions that demonstrate how to
19// use GL to display OpenNURBS objects.
20//
22
23#include "opennurbs.h"
24
25#if defined(ON_COMPILER_MSC)
26
27// Tested compilers:
28// Microsoft Developer Studio 6.0
29// Microsoft Visual Studio 2005
30// Support for other Windows compilers is not available.
31
32// Windows Open GL files require windows.h to be included before the
33// Open GL header files.
34#include <windows.h>
35#include <GL/gl.h> // Open GL basic definitions
36#include <GL/glu.h> // Open GL utilities (for GL NURBS stuff)
37
38#elif defined(ON_COMPILER_XCODE)
39
40// Tested compilers:
41// Apple XCode 2.4.1
42// Support for other Apple compilers is not available.
43#include <GLUT/glut.h> // Open GL auxillary functions
44
45#else
46
47// Unsupported compiler:
48// Support for other compilers is not available
49#include <GL/gl.h> // Open GL basic definitions
50#include <GL/glu.h> // Open GL utilities (for GL NURBS stuff)
51
52#endif
53
54
55#if !defined(OPENNURBS_GL_INC_)
56#define OPENNURBS_GL_INC_
57
58
59// Use ON_GL( const ON_Point, ...) to render single points.
60void ON_GL(
61 const ON_Point&
62 );
63
64// Use ON_GL( const ON_PointCloud, ...) to render Rhino point sets.
65void ON_GL(
66 const ON_PointCloud&
67 );
68
69// Use ON_GL( const ON_Mesh&, ...) to render OpenNURBS meshes.
70void ON_GL(
71 const ON_Mesh&
72 );
73
74// Use ON_GL( const ON_Brep&, ...) to render OpenNURBS b-reps.
75void ON_GL(
76 const ON_Brep&,
77 GLUnurbsObj*
78 );
79
80// must be bracketed by calls to glBegin(GL_POINTS) / glEnd()
81void ON_GL(
82 const ON_3dPoint&
83 );
84
85void ON_GL(
86 const ON_Curve&, //
87 GLUnurbsObj*, // created with gluNewNurbsRenderer
88 GLenum = 0, // type of curve (if 0, type is automatically set)
89 double[][4] = NULL // optional transformation applied to curve
90 );
91
92// must be bracketed by calls to gluBeginSurface( nobj )/gluEndSurface( nobj )
93void ON_GL(
94 const ON_Surface&, //
95 GLUnurbsObj* // created with gluNewNurbsRenderer
96 );
97
98// Use ON_GL( const ON_NurbsCurve&,...) in place of
99// gluNurbsCurve(). See your system's gluNurbsCurve() documentation
100// for details. In particular, for 3d curves the call to
101// ON_GL( const ON_NurbsCurve&, nobj,...) should appear inside
102// of a gluBeginCurve( nobj )/gluEndCurve( nobj ) pair.
103// Generally, the GL "type" should be set using the formula
104// ON_NurbsCurve:IsRational()
105// ? GL_MAP1_VERTEX_4
106// : GL_MAP1_VERTEX_3;
107void ON_GL(
108 const ON_NurbsCurve&, //
109 GLUnurbsObj*, // created with gluNewNurbsRenderer
110 GLenum = 0, // type of curve (if 0, type is automatically set)
111 int = 1, // bPermitKnotScaling - If true, curve knots may
112 // be rescaled to avoid knot vectors GL cannot handle.
113 double* = NULL, // knot_scale[2] - If not NULL and bPermitKnotScaling,
114 // the scaling applied to the knot vector is
115 // returned here.
116 double[][4] = NULL // optional transformation applied to curve
117 );
118
119void ON_GL( // low level NURBS curve renderer
120 int, int, int, int, // dim, is_rat, cv_count, order
121 const double*, // knot_vector[]
122 int, // cv_stride
123 const double*, // cv
124 GLUnurbsObj*, // created with gluNewNurbsRenderer
125 GLenum = 0, // type of curve (if 0, type is automatically set)
126 int = 1, // bPermitKnotScaling - If true, curve knots may
127 // be rescaled to avoid knot vectors GL cannot handle.
128 double* = NULL, // knot_scale[2] - If not NULL and bPermitKnotScaling,
129 // the scaling applied to the knot vector is
130 // returned here.
131 double[][4] = NULL // optional transformation applied to curve
132 );
133
134
135// Use ON_GL( const ON_NurbsSurface&,...) in place of
136// gluNurbsSurface(). See your system's gluNurbsSurface() documentation
137// for details. In particular, the call to
138// ON_GL( const ON_NurbsSurface&, nobj, ...) should appear inside
139// of a gluBeginSurface( nobj )/gluEndSurface( nobj ) pair.
140// Generally, the GL "type" should be set using the formula
141// ON_NurbsSurface:IsRational()
142// ? GL_MAP2_VERTEX_4
143// : GL_MAP2_VERTEX_3;
144void ON_GL(
145 const ON_NurbsSurface&, //
146 GLUnurbsObj*, // created with gluNewNurbsRenderer
147 GLenum = 0, // type of surface
148 // (if 0, type is automatically set)
149 int = 1, // bPermitKnotScaling - If true, surface knots may
150 // be rescaled to avoid knot vectors GL cannot handle.
151 double* = NULL, // knot_scale0[2] - If not NULL and bPermitKnotScaling,
152 // the scaleing applied to the first parameter is
153 // returned here.
154 double* = NULL // knot_scale0[2] - If not NULL and bPermitKnotScaling,
155 // the scaleing applied to the second parameter is
156 // returned here.
157 );
158
159
160// Use ON_GL( const ON_BrepFace&, nobj ) to render
161// the trimmed NURBS surface that defines a ON_Brep face's geometry.
162// The call to ON_GL( const ON_BrepFace&, nobj ) should
163// appear inside of a gluBeginSurface( nobj )/gluEndSurface( nobj )
164// pair.
165void ON_GL(
166 const ON_BrepFace&, //
167 GLUnurbsObj* // created with gluNewNurbsRenderer
168 );
169
170// Use ON_GL( const ON_Color ...) to set GL color to OpenNURBS color
171void ON_GL( const ON_Color&,
172 GLfloat[4]
173 );
174void ON_GL( const ON_Color&,
175 double, // alpha
176 GLfloat[4]
177 );
178
179// Use ON_GL( const ON_Material ...) to set GL material to OpenNURBS material
180void ON_GL(
181 const ON_Material&
182 );
183
184void ON_GL(
185 const ON_Material* // pass NULL to get OpenNURBS's default material
186 );
187
188// Use ON_GL( const ON_Light, ...) to add OpenNURBS spotlights to
189// GL lighting model
190void ON_GL(
191 const ON_Light*, // pass NULL to disable the light
192 GLenum // GL_LIGHTi where 0 <= i <= GL_MAX_LIGHTS
193 // See glLight*() documentation for details
194 );
195void ON_GL(
196 const ON_Light&,
197 GLenum // GL_LIGHTi where 0 <= i <= GL_MAX_LIGHTS
198 // See glLight*() documentation for details
199 );
200
202// Use ON_GL( ON_Viewport& ... ) to set the GL projections to match
203// those used in the OpenNURBS viewport.
204
206//
207// Use ON_GL( ON_Viewport&, in, int, int, int ) to specify the size of the
208// GL window and loads the GL projection matrix (camera to clip
209// transformation). If the aspect ratio of the GL window and
210// ON_Viewport's frustum do not match, the viewport's frustum is
211// adjusted to get things back to 1:1.
212//
213// For systems where the upper left corner of a window has
214// coordinates (0,0) use:
215// port_left = 0
216// port_right = width-1
217// port_bottom = height-1
218// port_top = 0
219void ON_GL( ON_Viewport&,
220 int, int, // port_left, port_right (port_left != port_right)
221 int, int // port_bottom, port_top (port_bottom != port_top)
222 );
223
225//
226// Use ON_GL( ON_Viewport& ) to load the GL model view matrix (world to
227// camera transformation).
228void ON_GL( const ON_Viewport& );
229
230// Use ON_GL( order, cv_count, knot, bPermitScaling, glknot )
231// to create knot vectors suitable for GL NURBS rendering.
232void ON_GL(
233 const int, // order, ON_NurbsCurve... order
234 const int, // cv_count, ON_NurbsCurve... cv count
235 const double*, // knot, ON_NurbsCurve... knot vector
236 GLfloat*, // glknot[] - GL knot vector
237 int = 0, // bPermitScaling - true if re-scaling is allowed
238 double* = NULL // scale[2] - If not NULL and bPermitScaling is true,
239 // then the scaling parameters are returned here.
240 // ( glknot = (knot = scale[0])*scale[1] )
241 );
242
243#endif
Definition opennurbs_point.h:403
Definition opennurbs_brep.h:980
Definition opennurbs_brep.h:1585
Definition opennurbs_color.h:24
Definition opennurbs_curve.h:88
Definition opennurbs_light.h:20
Definition opennurbs_material.h:25
Definition opennurbs_mesh.h:795
Definition opennurbs_nurbscurve.h:27
Definition opennurbs_nurbssurface.h:62
Definition opennurbs_pointcloud.h:26
Definition opennurbs_pointgeometry.h:24
Definition opennurbs_surface.h:58
Definition opennurbs_viewport.h:31
void ON_GL(const ON_Point &)
Definition opennurbs_gl.cpp:546
#define NULL
Definition opennurbs_system.h:256