使用g_resource_lookup_data()时提示资源文件不存在的问题求助
使用g_resource_lookup_data()时提示资源文件不存在的问题求助
大家好,我现在遇到了一个GResource相关的问题,想请各位帮忙排查一下。
我通过Meson的gnome.compile_resources()工具把文件编译成了GResource,目前已经成功获取到生成的源文件,#include "shader-resources.h"可以正常工作,调用shader_resources_get_resource()也没有报错。但当我尝试用g_resource_lookup_data()查找资源数据时,却一直收到错误提示:"The resource at “org/lyra/core/default.vert” does not exist"。
我不确定是不是资源文件的路径格式用错了,还是在其他环节漏掉了什么步骤?
以下是相关的C++代码片段(shader_resources是在单独头文件中定义的静态GResource*):
// 检查shader_resources是否存在,不存在则创建 if(shader_resources == nullptr) { shader_resources = shader_resources_get_resource(); // 输出default.vert的内容 GError* err = NULL; GBytes* data = g_resource_lookup_data(shader_resources, "org/lyra/core/default.vert", G_RESOURCE_LOOKUP_FLAGS_NONE, &err); if (err != NULL) { g_assert (data == NULL); g_print("Error: %s\n", err->message); g_error_free(err); } }
备注:内容来源于stack exchange,提问作者Joe Allen
相关产品推荐
相关产品推荐

