- float f = float(vec3(1, 1, 1));
DGL https://delphigl.com/forum/ |
|
vec3 zu float https://delphigl.com/forum/viewtopic.php?f=20&t=11746 |
Seite 1 von 1 |
Autor: | mathias [ Sa Sep 16, 2023 16:33 ] |
Betreff des Beitrags: | vec3 zu float |
Ich habe gerade gemerkt, das man so was komisches machen kann. Code:
Was kommt da bei f raus ? Irgendwie unlogisch, das dies kompiliert wird. |
Autor: | glAwesome [ Sa Sep 16, 2023 18:25 ] |
Betreff des Beitrags: | Re: vec3 zu float |
Nicht unlogisch, sondern genau so, wie es die Spezifikation vorsieht: Spezifikation von GLSL #version 330 hat geschrieben: Scalar constructors with non-scalar parameters can be used to take the first element from a non-scalar. For example, the constructor float(vec3) will select the first component of the vec3 parameter. (Abschnitt 5.4.1 "Conversion and Scalar Constructors") Im Grunde ist es nur konsequent, dass die Spezifikation dies erlaubt. Ein float ist ja sozusagen ein "vec1". Und auf die gleiche Weise kannst du ja auch bei einem vec3 oder vec4 die letzten Komponenten "abschneiden": Code:
|
Autor: | mathias [ So Sep 17, 2023 13:03 ] |
Betreff des Beitrags: | Re: vec3 zu float |
Etwas doof, aber man kann damit leben, wen man es weis. |
Seite 1 von 1 | Alle Zeiten sind UTC + 1 Stunde |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |