Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What about the types int2, int3, float2, float3 etc

Tags:

c++

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?

EDIT:

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.).

like image 914
Moberg Avatar asked Nov 02 '10 15:11

Moberg


People also ask

What is INT2 in c++?

INT2. A 2-byte signed integer. signed short. INT4. A 4-byte signed integer.

Whats 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.).

What is float3 in C++?

float3(Boolean)Constructs a float3 vector from a single bool value by converting it to float and assigning it to every component.


2 Answers

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 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.

like image 118
jalf Avatar answered Sep 30 '22 11:09

jalf


They are used in CUDA (and openCL?) where you have specific sized floats and memory usage and alignment is a big deal.

like image 25
Martin Beckett Avatar answered Sep 30 '22 12:09

Martin Beckett