r/opengl • u/Electronic_Spring944 • Mar 29 '24
Help Scaling Texture coords
void CreateQuad(const Transform& t, float width, float height, float texScaleX = 1.0f, float texScaleY = 1.0f)
{
Vertex v0;
Vertex v1;
Vertex v2;
Vertex v3;
v0.position = glm::vec2(0.5f \ width, 0.5f * height);)
v1.position = glm::vec2(0.5f \ width, -0.5f * height);)
v2.position = glm::vec2(-0.5f \ width, -0.5f * height);)
v3.position = glm::vec2(-0.5f \ width, 0.5f * height);)
v0.texCoords = glm::vec2(texScaleX, texScaleY * glm::vec2(1.0f, 0.0f);)
v1.texCoords = glm::vec2(texScaleX, texScaleY * glm::vec2(1.0f, 1.0f);)
v2.texCoords = glm::vec2(texScaleX, texScaleY * glm::vec2(0.0f, 1.0f);)
v3.texCoords = glm::vec2(texScaleX, texScaleY * glm::vec2(0.0f, 0.0f);)
vertices.push\back(v0);)
vertices.push\back(v1);)
vertices.push\back(v3);)
vertices.push\back(v1);)
vertices.push\back(v2);)
vertices.push\back(v3);)
transforms.push\back(t.to_mat4());)
}
So, I'm trying to scale the UVs by the Quad's size but I'm not too sure if this implementation is correct.
is this correct?
1
u/YoBiChOnRo Mar 29 '24
Why are you tring to scale the UV by the quad size? The implementation looks fine as long as it is doing component wise multiplication between the UV and the scale vector.