How to load JPG/PNG Textures in an SDL/OpenGL App under OSX

后端 未结 4 1036
长情又很酷
长情又很酷 2020-12-10 06:27

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

4条回答
  •  青春惊慌失措
    2020-12-10 06:52

    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.

    Sample taken from the SDL_image documentation:

    // Load sample.png into image
    SDL_Surface* image = IMG_Load("sample.png");
    if (image == nullptr) {
        std::cout << "IMG_Load: " << IMG_GetError() << "\n";
    }
    

提交回复
热议问题