OpenGL 纹理,不喜欢我的 bmp

发布于 2024-10-03 17:38:32 字数 349 浏览 0 评论 0原文

别担心,我不想问如何使用纹理。 :)

我的问题是: 我正在使用几种纹理。但如果我想像这样更改文件名:

(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心奴独伤 2024-10-10 17:38:32

最有可能的是,这些纹理使用不同的格式(.bmp 不仅仅是一种格式),而您的函数仅支持一种格式。

最简单、最好的解决方案是使用一个好的库来加载纹理,而不是使用一些神秘的 LoadBMP。我推荐 SOIL - 简单的 OpenGL 图像加载器。 只需将其添加到您的项目中,您就可以通过单个函数调用将任何 bmpjpgpng 纹理加载到 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 any bmp, jpg or png textures to an OpenGL texture ID with a single function call.

甜心 2024-10-10 17:38:32

可以假设您的第二个 BMP 具有错误的内部数据格式(非 BGR 或类似的格式)。同意科斯的观点 - 您应该尝试使用一些库来实现此目的。有很多这样的 - SFMLSDL_imageDevIL...

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...

羞稚 2024-10-10 17:38:32

非工作纹理的维度是否为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文