简体   繁体   English

OpenGL 使纹理按比例放大而不是钳位

[英]OpenGL make texture scale up and not clamp

I have a texture in a game that clamps to the edge instead of linearly scaling up.我在游戏中有一个纹理,它夹在边缘而不是线性放大。 These are the parameters I'm providing OpenGL with:这些是我为 OpenGL 提供的参数:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EGDE);

How should I change them in order to make the texture scale up?我应该如何更改它们以使纹理按比例放大?

These are the vertices I'm giving OpenGL:这些是我给 OpenGL 的顶点:

typedef struct{
  float positionX;
  float positionY;
  float textureX ;
  float textureY ;
} textureVertex;

textureVertex vertices[4] = {
      {-3.5f,  3.5f, -1.0f,  1.0f},
      {-3.5f, -3.5f, -1.0f, -1.0f},
      { 3.5f, -3.5f,  1.0f, -1.0f},
      { 3.5f,  3.5f,  1.0f,  1.0f}
    };

You should specify texture coordinates for your vertices.您应该为顶点指定纹理坐标。 CLAMP just tells OpenGL what to do when the coordinates go outside the range 0 -> 1. It does not say where that range is . CLAMP 只是告诉 OpenGL 当坐标 go 超出范围 0 -> 1 时该怎么办。它没有说明该范围在哪里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM