gpt4 book ai didi

opengl - 'f' 在 OpenGL 函数(如 glRotatef)中意味着什么?

转载 作者:行者123 更新时间:2023-12-04 13:23:52 25 4
gpt4 key购买 nike

实际上 OpenGL(或至少 PyOpenGL)中的每个函数都在末尾有一个 f,例如 glRotatefglColor3f 等。 ,但我不知道它是什么意思。它是否像默认使用单精度 float 的 1.0f 一样工作?

虽然我在这里(如果允许我问 2 个问题),glColor3fglColor3fv 之间有什么区别?

最佳答案

f 表明该函数需要一个float。因此,如果有一个 i 告诉该函数需要一个 intv 表示一个向量,因此 glColor3fv 需要一个“浮点向量”,换句话说就是一个 float 组。

这清楚地反射(reflect)在 glColor 的文档中.

void glColor3f(GLfloat red, GLfloat green, GLfloat blue);
void glColor3fv(const GLfloat *v);

格式在规范中有更明确的解释:

A final v character, if present, indicates that the command takes a pointer to an array (a vector) of values rather than a series of individual arguments.

In general, a command declaration has the form

rtype Name{∈1234}{∈ b s i i64 f d ub us ui ui64}{∈v}

rtype is the return type of the function. The braces ({}) enclose a series of type descriptors (see the table bellow), of which one is selected. ∈ indicates no type descriptor.

If there are no letters, then the arguments’ type is given explicitly. If the final character is not v, then N is given by the digit 1, 2, 3, or 4 (if there is no digit, then the number of arguments is fixed).

If the final character is v, then only arg1 is present and it is an array of N values of the indicated type.

+------+----------------------------------+
| Type | Descriptor Corresponding GL Type |
+------+----------------------------------+
| b | byte |
| s | short |
| i | int |
| i64 | int64 |
| f | float |
| d | double |
| ub | ubyte |
| us | ushort |
| ui | uint |
| ui64 | uint64 |
+------+----------------------------------+

OpenGL 4.5 Specification, Page 11 and 12

ε 符号表示“是...的一个元素”。

相同的原则用于各种事物,例如 GL_RGBA32FGL_RGBA8I。这不是 OpenGL 特有的,各种库使用它期望或返回的类型的前缀。

关于opengl - 'f' 在 OpenGL 函数(如 glRotatef)中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43548733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com