OpenGL 纹理,不喜欢我的 bmp
别担心,我不想问如何使用纹理。 :)
我的问题是: 我正在使用几种纹理。但如果我想像这样更改文件名:
(LoadBMP("grass.bmp", textureImage[3])) // I can see the grass
到
(LoadBMP("parkett.bmp", textureImage[3])) // No texture, only white color
两张图片都在同一个目录中并且没有错误消息。
有什么想法吗? 谢谢 索尼娅 (OpenGL、Visual Studio C++ 2010)
don't worry, I don't want to ask how to use textures. :)
My problem is:
I'm using several textures. But if I want to change the file name like this:
(LoadBMP("grass.bmp", textureImage[3])) // I can see the grass
to
(LoadBMP("parkett.bmp", textureImage[3])) // No texture, only white color
Both pictures are in the same directory and there is no error message.
Any ideas?
Thanks
Sonja
(OpenGL, Visual Studio C++ 2010)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最有可能的是,这些纹理使用不同的格式(
.bmp
不仅仅是一种格式),而您的函数仅支持一种格式。最简单、最好的解决方案是使用一个好的库来加载纹理,而不是使用一些神秘的
LoadBMP
。我推荐 SOIL - 简单的 OpenGL 图像加载器。 只需将其添加到您的项目中,您就可以通过单个函数调用将任何bmp
、jpg
或png
纹理加载到 OpenGL 纹理 ID。Most likely, those textures use a different format (
.bmp
is not just a single format) and your function only supports one.The simplest and best solution is to use a good library to load your textures, instead of some mystical
LoadBMP
. I recommend SOIL - Simple OpenGL Image Loader. Just add it to your project and you'll be able to load anybmp
,jpg
orpng
textures to an OpenGL texture ID with a single function call.可以假设您的第二个 BMP 具有错误的内部数据格式(非 BGR 或类似的格式)。同意科斯的观点 - 您应该尝试使用一些库来实现此目的。有很多这样的 - SFML,SDL_image,DevIL...
Can just assume your second BMP has wrong internal data format (non-BGR or something like that). Agreed with Kos - you should try using some libraries for this purpose. There are lots of 'em - SFML, SDL_image, DevIL...
非工作纹理的维度是否为 2 次幂(即 1、2、4、8、16、32...)?如果没有,那就是它不起作用的原因。无论是秤还是垫。
Are the dimensions of the non-working texture powers of 2 (i.e. 1, 2, 4, 8, 16, 32, ...)? If not, then that's why it's not working. Either scale or pad.