LearnOpenGL-CN icon indicating copy to clipboard operation
LearnOpenGL-CN copied to clipboard

纹理那节,没有出现笑脸图,而是白板

Open chiyandetaotie opened this issue 6 years ago • 4 comments

在学习纹理的时候没有出现笑脸图,而是白板,不知道怎么弄。我跑的是最后那个源代码。 在代码中由于 unsigned char *data = stbi_load(FileSystem::getPath("resources/textures/container.jpg").c_str(), &width, &height, &nrChannels, 0); 报错,我直接改为 unsigned char *data = stbi_load("...\container.jpg", &width, &height, &nrChannels, 0);了,不知道是这个原因吗? 在编写4.2.texture.fs和4.2.texture.vs时,我是使用记事本写的文本文档,这样对吗?

1 而是 2

chiyandetaotie avatar Feb 21 '19 23:02 chiyandetaotie

我也是一样,你那个应该是vs或者fs文件读取错误了,我这边是直接glTexImage2D()函数无法调用,一调用会报错,ig9icd32.dll异常

Jiondon avatar Mar 16 '19 07:03 Jiondon

unsigned char *data = stbi_load("...\container.jpg", &width, &height, &nrChannels, 0);了,不知道是这个原因吗?

这一行的路径可能有问题.最开始的”..”表示上一层目录,’.’表示当前目录,’…’是什么就不知道了

echofff avatar Mar 17 '19 06:03 echofff

我也遇到这个问题了,但我加了data是否存在的判断,确认了是资源路径加载错误,可以在解决方案查看图片路径,再讲路径写入stbi_load

lwg96 avatar Aug 24 '19 08:08 lwg96

可以运行,结果正确。确保您的 *.vs, *fs,在指定目录之中。

chatyan avatar Oct 03 '19 06:10 chatyan