Reputation: 65
Can I use the 3D tex coord function for 2D textures by setting the Z value to 0 in OpenGL 2.1? Are there any 3D functions that I can not use for 2D? I can't use 2D functions because this is for a 2D/3D wrapper and it's too inefficient to try and guess if the user is inputting 2D or 3D coords when both functions could be used together.
Upvotes: 0
Views: 139
Reputation: 43359
This is going to sound funny, but all texture coordinates in OpenGL are always 4D. As are vertex positions.
To help explain this better, consider a deprecated function like glTexCoord2f (...)
- it automatically assigns r
= 0.0 and q
= 1.0. This behavior is extended to vertex arrays, if you have a texture coordinate pointer that only supply 2 components, GL automatically assigns 0.0 and 1.0 to the remaining 2 as illustrated above.
I would suggest you use the nomenclature strq
when referring to texture coordinates, by the way. You can access them as xyzw
in a shader, but the (fixed-function) pipeline is always documented as referring to them by strq
.
Upvotes: 2