简体   繁体   English

OpenGl 2d Texture重复(在不同设备上的不同结果)

[英]OpenGl 2d Texture repeat (different results on different devices)

On my laptop (Intel HD Graphics) when I try to draw a texture it will wrap correctly. 当我尝试在笔记本电脑(英特尔高清显卡)上绘制纹理时,它将正确包裹。 However when I use my desktop with a nvidia graphics card it won't wrap anymore and it will clamp to 0..1. 但是,当我将台式机与nvidia显卡一起使用时,它将不再缠绕,并且将钳位到0.1.1。 My image loading coding is posted below. 我的图像加载编码如下。 As you can see i explicitly set the texture wrap to repeat. 如您所见,我明确地将纹理环绕设置为重复。

int x, y, comp;
GLuint texID;
unsigned char* data = stbi_load(filename, &x, &y, &comp, 0);
glGenTextures(1, &texID); 
glBindTexture(GL_TEXTURE_2D, texID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, x, y, 0, (comp == 3) ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
stbi_image_free(data);
m_resourceMap[resID] = texID;

SOLVED It had to do with the way Intel HD Graphics and Nvidia implement GLSL. 已解决它与Intel HD Graphics和Nvidia实施GLSL的方式有关。 For some reason it Inte l implementation didn't like my shader program which transformed vertex coordinates to texture coordinates. 由于某种原因,它的Inte l实现不喜欢我的着色器程序,该程序将顶点坐标转换为纹理坐标。 however Intel didnt like this and wouldn't work unless i mapped the tex coords using gltexcoordpointer. 但是,英特尔不喜欢这样,除非我使用gltexcoordpointer映射了tex坐标,否则它将无法正常工作。 so when I tested it out on nvidia, my old shader program which mapped texture coordinates worked fine and nvidia's implementation ignored my gltexcoordpointer mapping. 因此,当我在nvidia上进行测试时,我的旧着色器程序(映射纹理坐标)工作正常,nvidia的实现忽略了gltexcoordpointer映射。 I solved it by just making an attribute to pass in properly. 我通过使属性正确传递来解决它。

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

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