当前位置:网站首页>API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T

API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T

2022-07-06 10:36:00 hankern

Set texture coordinates beyond 0-1 How to handle range .

Using functions glTexParameteri() Set texture parameters .

// Set texture parameters  GL_TEXTURE_WRAP_S   by  GL_REPEAT  Represent texture X Direction cycling textures    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
// Set texture parameters  GL_TEXTURE_WRAP_T   by  GL_MIRRORED_REPEAT  Represent texture Y Direction mirroring loops through textures 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);

Value GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, GL_MIRRORED_REPEAT, GL_REPEAT, GL_MIRROR_CLAMP_TO_EDGE, The default value GL_REPEAT

There are also places to say value GL_CLAMP, Its effect and GL_CLAMP_TO_EDGE almost .

1、GL_CLAMP_TO_EDGE

Take the boundary color when the texture coordinates exceed .


2、GL_CLAMP_TO_BORDER

Texture coordinates out of range, take the border color , You need to set the border color through the following code .

float borderColor[] = {1.0f, 1.0f, 0.0f, 1.0f};
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);

 


3、GL_MIRRORED_REPEAT

When the integer part of texture coordinates is odd , Set the coordinates to the decimal part of the texture coordinates ; If the integer part is even , Then the coordinates are set to 1 - The fractional part , The decimal part here represents the decimal part after removing the integer part .


4、GL_REPEAT

Make the integer part of the coordinate be ignored ,GL Use only the decimal part , So as to create a repeated configuration .


5、GL_MIRROR_CLAMP_TO_EDGE

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

原网站

版权声明
本文为[hankern]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131709023795.html