问题描述
我看过使用这些类型的不同代码片段,但我还没有看到他们是否在一些<标准头文件>或者只是在本地头文件或甚至在文件级别定义。
I've seen different code snippets using these types, but I haven't seen if they are defined in some <standard header file> or just defined in a "local header file" or even at file level.
所以,我想知道是否有定义这些类型的标准头文件?
So what Im wondering is: Is there any standard header file that defines these types? Or is there some standard definitions that everyone uses that I should copy?
我想这些类型的一个可能和常见的用法是代表坐标,我错了吗?
I guess that a possible and common use to these types are representing coordinates, am I wrong?
如果我想用这些来表示网格中的位置,还有什么我应该考虑的吗?为什么或为什么不使用它们的原因?
Is there anything else I should think about if I want to use these to represent positions in a grid? Any reasons why or why not to use them?
编辑:
澄清:int2表示一对int ,float3表示浮点数的三元组。
Clarification: int2 means a pair of ints, float3 means a triplet of floats.
如果这些类型是预定义的,那么使用它们将是很好的,而不必从头开始写,包括标准代数函数操作符+,操作符等)。
If these types were predefined somewhere it would be nice to use them instead of having to write it from scratch including the standard algebraic functions (operator+, operator-, etc.).
推荐答案
这些类型不是标准C ++的一部分。
These types aren't a part of standard C++. They might either be defined in some third-party library, or you're looking at some other dialect or language.
GPU代码(着色器语言,如GLSL,Cg或其他语言) HLSL或GPGPU的东西,如CUDA或OpenCL)通常定义类似这样的类型,作为相应SIMD数据类型的名称。
GPU code (Shader languages such as GLSL, Cg or HLSL, or GPGPU stuff like CUDA or OpenCL) typically defines types like these though, as names for the corresponding SIMD datatypes.
这篇关于对于类型int2,int3,float2,float3等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!