0

私は stbi_load を使用して次の関数を持っています:

void load_texture_from_file(const char *file, bool alpha, const char *name) {
    Texture *tex;
    tex = malloc(sizeof(Texture));
    tex->name = name;

    int width, height, channels;
    unsigned char *data = stbi_load(file, &width, &height, &channels, 0); 
    generate_texture(width, height, data, tex, alpha); 
    
    stbi_image_free(data);
}

ファイルの送信元:

load_texture_from_file("/home/correct_folder/correct_name.png", true, "sprite");

stbi_failure_reason() を使用してもエラーは発生せず、gdb でデータの内容を確認すると、次のように表示されます。

Thread 1 "a" hit Breakpoint 2, load_texture_from_file (file=0x555555579d18 "/home/correct_folder/correct_name.png", 
    alpha=true, name=0x555555579d12 "face") at resource_manager.c:25
25          generate_texture(width, height, data, tex, alpha); 
(gdb) print data
$1 = (unsigned char *) 0x7ffff40c1010 ""

私は何が欠けていますか?

4

1 に答える 1