OpenGL学习笔记(二)

本文详细介绍了OpenGL中基本的图形元素类型,包括GL_POINTS、GL_LINES、GL_LINE_STRIP、GL_LINE_LOOP、GL_TRIANGLES、GL_TRIANGLE_STRIP、GL_TRIANGLE_FAN、GL_QUADS、GL_QUAD_STRIP和GL_POLYGON。这些类型用于绘制点、线、面等图形,通过它们可以构建出复杂的3D场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OpenGL的基本图形元素类型(Primitive Types)包括:

  • GL_POINTS Use this primitive type to render mathematical points. OpenGL renders a point for each vertex specified.

  • 点。这个图形元素用来渲染数学意义的点。OpenGL渲染每一个指定的顶点。
  • GL_LINES Use this primitive to draw unconnected line segments. OpenGL draws a line segment for each group of two vertices. If the application specifies n vertices, OpenGL renders n/2 line segments. If n is odd, OpenGL ignores the final vertex.

  • 线。OpenGL用这种元素来绘制不连续的线段。OpenGL对每组两个点之间画一条线段。如果应用程序给出了n个顶点,OpenGL则绘制出n/2条线段。如果n为奇数,则自动忽略最后一个顶点。
  • GL_LINE_STRIP Use this primitive to draw a sequence of connected line segments. OpenGL renders a line segment between the first and second vertices, between the second and third, between the third and fourth, and so on. If the application specifies n vertices, OpenGL renders n1 line segments.

  • 多线段。OpenGL使用这种元素绘制一系列连在一起的线段。OpenGL在第一个和第二个顶点间画一条线段,在第二和第三个点间,第三和第四个点,以此类推。如果应用给出了n个顶点,则OpenGL画出n-1条线段。
  • GL_LINE_LOOP Use this primitive to close a line strip. OpenGL renders this primitive like a GL_LINE_STRIP with the addition of a closing line segment between the final and first vertices.

  • 包围线段。OpenGL使用这种元素绘制封闭的多线段。OpenGL绘制这种元素的方式和多线段的方式类似,只不过会在最后一个顶点和第一个顶点间绘制一条用于封闭的线段。
  • GL_TRIANGLES Use this primitive to draw individual triangles. OpenGL renders a triangle for each group of three vertices. If your application specifies n vertices, OpenGL renders n/3 triangles. If n isn't a multiple of 3, OpenGL ignores the excess vertices.

  • 三角形。用于绘制独立的三角形。OpenGL针对每组三个顶点画出一个三角形。如果应用给出了n个顶点,OpenGL绘制出n/3个三角形。如果n不是3的倍数,则忽略掉多余的顶点。
  • GL_TRIANGLE_STRIP Use this primitive to draw a sequence of triangles that share edges. OpenGL renders a triangle using the first, second, and third vertices, and then another using the second, third, and fourth vertices, and so on. If the application specifies n vertices, OpenGL renders n2 connected triangles. If n is less than 3, OpenGL renders nothing.

  • 连续三角形。用于绘制共享一边的一系列三角形。OpenGL对第一、二、三顶点绘制一个三角形,然后用第二、三、四顶点绘制第二个三角形,以此类推。如果应用给出n个顶点,OpenGL绘制n-2个连在一起的三角形。如果n小于3,则不会绘制任何东西。
  • GL_TRIANGLE_FAN Use this primitive to draw a fan of triangles that share edges and also share a vertex. Each triangle shares the first vertex specified. If the application specifies a sequence of vertices v, OpenGL renders a triangle using v0, v1, and v2; another triangle using v0, v2, and v3; another triangle using v0, v3, and v4; and so on. If the application specifies n vertices, OpenGL renders n2 connected triangles. If n is less than 3, OpenGL renders nothing.

  • 三扇形。用于绘制共享三角形一条边和一个顶点的三角形,并最终形成扇形。每个三角形都共用给出的第一个顶点。如果应用给出了一系列顶点v,OpenGL使用v0、v1、v2画一个三角形;然后用v0、v2、v3画第二个;下一个则用v0、v3、v4;以此类推。如果应用给出了n个顶点,则绘制出n-2个三角形。如果n小于3,则什么都不会被绘制出来。
  • GL_QUADS Use this primitive to draw individual convex quadrilaterals. OpenGL renders a quadrilateral for each group of four vertices. If the application specifies n vertices, OpenGL renders n/4 quadrilaterals. If n isn't a multiple of 4, OpenGL ignores the excess vertices.

  • 四边形。用来绘制独立的凸出的四边形。OpenGL对每组四个顶点绘制一个四边形。如果应用给出n个顶点,则绘制出n/4个四边形。如果n不是4的倍数,则忽略掉多余的顶点。
  • GL_QUAD_STRIP Use this primitive to draw a sequence of quadrilaterals that share edges. If the application specifies a sequence of vertices v, OpenGL renders a quadrilateral using v0, v1, v3, and v2; another quadrilateral using v2, v3, v5, and v4; and so on. If the application specifies n vertices, OpenGL renders (n-2)/2 quadrilaterals. If n is less than 4, OpenGL renders nothing.

  • 连续的四边形。用于绘制共享一边的一系列四边形。如果应用给出一系列顶点v,则用v0、v1、v3、v2;另一个四边形用v2、v3、v5、v4;以此类推。如果应用给出n个顶点,则会绘制出(n-2)/2个四边形。如果n小于4,则什么都不绘制。
  • GL_POLYGON Use GL_POLYGON to draw a single filled convex n-gon primitive. OpenGL renders an n-sided polygon, where n is the number of vertices specified by the application. If n is less than 3, OpenGL renders nothing.
  • 多边形。用于绘制n点的面。OpenGL绘制一个n边的多边形。这里n是应用给出的顶点数。如果n小于3,则什么都不会绘制出来。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值