问题描述
我正在编写一个在OSX下运行的SDL/OpenGL应用程序.我必须使用现有的代码,该代码使用DevIL库加载JPG和PNG纹理.不幸的是,这在OS X下效果非常差,因此我决定完全不使用DevIL,并使用另一个库重写应用程序的各个部分.我想保持它的灵活性(DevIL可以处理许多图像格式)并且易于使用.您可以推荐一个不错的DevIL替代品吗?该应用程序完全用C ++编写.
i am writing an SDL / OpenGL application that runs under OSX. I have to use existing code which uses the DevIL library for loading JPG and PNG textures. Unfortunately, this works very bad under OS X, so i decided not to use DevIL at all, and rewrite the respective parts of the application using another library. I want to keep it flexible (DevIL can handle a lot of image formats) and easy to use. Is there a good replacement for DevIL that you can recommend? The application is entirely written in C++.
推荐答案
看看 SDL_image 库.它提供了类似IMG_LoadPNG
的功能,可以将图片作为" SDL_Surface加载.由于您已经在使用SDL,因此它应该非常适合您的程序.
Have a look at the SDL_image library. It offers functions like IMG_LoadPNG
that load your picture "as an" SDL_Surface.Since you already work with SDL this should fit quite well in your program.
摘录自 SDL_image文档:
// Load sample.png into image
SDL_Surface* image = IMG_Load("sample.png");
if (image == nullptr) {
std::cout << "IMG_Load: " << IMG_GetError() << "\n";
}
这篇关于如何在OSX下的SDL/OpenGL应用程序中加载JPG/PNG纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!