openGL系列文章目录
前言
openGLAPI之glPolygonOffset函数详解
一、glPolygonOffset官方文档
glPolygonOffset官方文档说明
Name
glPolygonOffset — set the scale and units used to calculate depth values
C Specification
void glPolygonOffset( GLfloat factor,
GLfloat units);
Parameters
factor
Specifies a scale factor that is used to create a variable depth offset for each polygon. The initial value is 0.
units
Is multiplied by an implementation-specific value to create a constant depth offset. The initial value is 0.
Description
When GL_POLYGON_OFFSET_FILL, GL_POLYGON_OFFSET_LINE, or GL_POLYGON_OFFSET_POINT is enabled, each fragment’s depth value will be offset after it is interpolated from the depth values of the appropriate vertices. The value of the offset is factor×DZ+r×units, where DZ is a measurement of the change in depth relative to the screen area of the polygon, and r is the smallest value that is guaranteed to produce a resolvable offset for a given implementation. The offset is added before the depth test is performed and before the value is written into the depth buffer.
glPolygonOffset is useful for rendering hidden-line images, for applying decals to surfaces, and for rendering solids with highlighted edges.
Associated Gets
glIsEnabled with argument GL_POLYGON_OFFSET_FILL, GL_POLYGON_OFFSET_LINE, or GL_POLYGON_OFFSET_POINT.
glGet with argument GL_POLYGON_OFFSET_FACTOR or GL_POLYGON_OFFSET_UNITS.
Version Support
OpenGL Version
Function / Feature Name 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5
glPolygonOffset ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
See Also
glDepthFunc, glEnable, glGet, glIsEnabled
Copyright
Copyright © 1991-2006 Silicon Graphics, Inc. Copyright © 2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see https://khronos.org/registry/OpenGL-Refpages/LICENSES/LicenseRef-FreeB.txt.
二、翻译
glPolygonOffset 函式
發行項
2021/09/15
2 位參與者
GlPolygonOffset 函式會設定 OpenGL 用來計算深度值的小數位數和單位數。
語法
C++
複製
void glPolygonOffset(
GLfloat factor,
GLfloat units
);
參數
因素
指定用來為每個多邊形建立可變深度位移的比例因數。 初始值為零。
單位
指定乘以實值指定值的值,以建立常數深度位移。 初始值為0。
傳回值
此函式不會傳回值。
錯誤碼
GlGetError函式可以取出下列錯誤碼。
錯誤碼
Name 意義
GL _ 不正確 _ 操作
呼叫 glBegin 和對應的 glEnd呼叫之間呼叫了函數。
備註
當 _ 啟用 GL 多邊形 _ 位移時,每個片段的深度值將會在從適當頂點的深度值中插補之後位移。 位移的值是 係數 * ? z + r * 單位,其中? z 是相對於多邊形螢幕區域的變更深度度量,而 r 是保證為指定的執行產生可解析位移的最小值。 在執行深度測試之前,以及將值寫入深度緩衝區之前,會加入位移。
GlPolygonOffset 函式適用于轉譯隱藏行影像、將 decals 套用至表面,以及用來呈現具有反白顯示邊緣的純色。
GlPolygonOffset 函式對在意見緩衝區中放置的深度座標沒有任何作用。 它也不會影響選取專案。
下列函式會取出與 glPolygonOffset 相關的資訊:
具有引數 GL _ 多邊形 _ 位移 _ 因數的 glGet
具有引數 GL _ 多邊形 _ 位移 _ 單位的 glGet
具有引數 GL _ 多邊形 _ 位移 _ 填滿的 glIsEnabled
具有引數 GL _ 多邊形 _ 位移 _ 線的 glIsEnabled
具有引數 GL _ 多邊形 _ 位移 _ 點的 glIsEnabled
注意
GlPolygonOffset 函式僅適用于 OpenGl 1.1 版或更高版本。
規格需求
規格需求
需求 值
最低支援的用戶端
Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器
Windows 2000 Server [僅限傳統型應用程式]
標頭
Gl
程式庫
Opengl32 .lib
DLL
Opengl32.dll
另請參閱
glDepthFunc
glDisable
glEnable
glGet
glIsEnabled
glLineWidth
glStencilOp
glTexEnv