简体   繁体   English

SDL2 IMG_LoadTexture无法从资产中找到纹理-Android

[英]SDL2 IMG_LoadTexture can't find the texture from asset - Android

I'm trying to understand why SDL2 compiled for Android can't find the JPG (or bmp,or png) texture file using this code: 我试图理解为什么为Android编译的SDL2无法使用以下代码找到JPG(或bmp或png)纹理文件:

/** Prepare textures */
static SDL_Texture *img = NULL;
int w, h; // texture width & height
          // load our image

if (img == NULL) {
    img = IMG_LoadTexture(state->renderers[0], "background.jpg");

    if (img != NULL)
    {
        SDL_Log("Image loaded ok %s\n", "background.jpg");
    } else {
        SDL_Log("Error loading Image: %s\n", "background.jpg");
    }

I'm adding the background.jpg file in the assets folder of the project and it is added to the APK file, so I don't know what's happening, if you know something i'm missing ... 我在项目的Assets文件夹中添加background.jpg文件,并将其添加到APK文件中,所以我不知道发生了什么,如果您知道我所缺少的内容...

Ok, the problem was the sdl image library was not being initialized with IMG_INIT(flags) and you have to compile sdl image with load_jpg parameter set in the compiler. 好的,问题是未使用IMG_INIT(flags)初始化sdl图像库,您必须使用在编译器中设置了load_jpg参数的sdl图像进行编译。 Once you do both things you are ready to go 一旦做完这两件事,就可以开始了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM