CAP 4703Computer Graphic Methods.ppt
《CAP 4703Computer Graphic Methods.ppt》由会员分享,可在线阅读,更多相关《CAP 4703Computer Graphic Methods.ppt(55页珍藏版)》请在麦多课文档分享上搜索。
1、CAP 4703 Computer Graphic Methods,Prof. Roy Levow Lecture 2,2-Dimensional Drawing with OpenGL,Two-dimensional objects are a special case of three-dimensional figures The drawing is limited (by the programmer) to a plane Viewing is normally an orthogonal view, perpendicular to the drawing plane,Sierp
2、inski Gasket,A simple but interesting example Start with any triangle Pick an internal point at random Pick a vertex at random Find the midpoint between 1 and 2 Display this point Replace initial point with this one Repeat from step 2,Sierpinski Gasket Construction,OpenGL Program for Sierpinski Gask
3、et,main() initialize_the_system();for (some_number_of_points)pt = generate_a_point();display_the_point(pt);cleanup();return 0; ,Points or Vertices,Points are represented by vectors with an entry for each coordinatep = (x, y, z) in 3 dimensionsp = (x, y, 0) gives 2 dimensions by always setting z to 0
4、 OpenGL allows up to 4 dimensions Internal representation is always the same,OpenGL Vertices,Vertex creating functions have general nameglVertex*The suffix is 2 or 3 characters Number of dimensions: 2, 3, or 4 Data type: i = integer, f = float, d = double Optional v if pointer,Underlying Representat
5、ion,OpenGL data types are defined in header file#define GLfloat float so a header might look likeglVertex2i(GLint xi, GLint yi) orglVertex3f(GLfloat xf, GLfloat yf,GLfloat zf),Representation (cont.),For the vector formGLfloat vertex3; and then useglVertex3fv(vertex);,Defining Geometric Objects,Objec
6、ts are defined by collections of point constructors bounded by calls to glBegin and glEnd A line is defined byglBegin(GL_LINES);glVertex2f(x1, y1);glVertex2f(x2, y2);glEnd();,OpenGL Code for Sierpinski Gasket,See p. 41 of textCode leaves many open questions by using default values colors image posit
7、ion size clipping? persistence,A Resulting Image,Coordinate System,Early systems depended on specific device mapping Device-independent graphics broke link Use application or problem coordinate system to define image Use device coordinates, raster coordinates, screen coordinates for device,Coordinat
8、es,Application coordinates can be integer or real and multi-dimensional Screen or raster coordinates are always integer and essentially 2-dimensional Graphics program maps application coordinates onto device coordinates,App to Device Mapping,Classes for OpenGL Functions,Primitives draw points, line
9、segments, polygons, text, curves, surfaces Attributes specify display characteristics of objects: color, fill, line width, font Viewing determine aspects of view: position and angle of camera, view port size, ,Function Classes (cont),Transformations change appearance or characteristics of objects: r
10、otate, scale, translate Input handle keyboard, mouse, etc. Control communicate with window system Inquiry get display information: size, raster value, ,OpenGL Interface,Graphics Utility Interface (GLU) Creates common objects like spheres GL Utility Toolkit (GLUT) Provides generic interface to window
11、 system GLX for Unix/Linux and wgl for Microsoft Windows provide low-level glue to window system,Library Organization,Using Libraries,Header files #include #include #include On some systems the GL/ is not used,Primitives,OpenGL supports both geometric primitives and raster primitives,Geometric Primi
12、tives,Points = GL_POINTS vertex displayed with size = 1 pixel Line segments = GL_LINES defined by pairs of vertices as endpoints of segments Polygons = GL_LINE_STRIPE or GL_LINE_LOOP Loop is closed, stripe is not,Primitive Examples,Properties of Polygons,Defined by line loop border Simple if no edge
13、s cross Convex if every line segment connecting pair of points on boundary or inside lies completely inside,Polygon Types in OpenGL,Polygons are either filled regions (default) or boundaries Set with glPolygonMode To get polygon with boundary must draw twice, once as filled and once as boundary or l
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CAP4703COMPUTERGRAPHICMETHODSPPT
