Load images

HI

at line: std::string imgfile = “./data/images/image” + std::to_string(i + 1) + “.png”;
it tries to open the *.wasm file? I have the data folder aside the wasm file and also in PackageSources folder.

constexpr int imageCount = 3;
for (int i = 0; i < imageCount; ++i) {
	std::string imgfile = "./data/images/image" + std::to_string(i + 1) + ".png";
	gData.images[i] = nvgCreateImage(vg, imgfile.c_str(), 0);
	if (gData.images[i] == 0) {
		std::cerr << "Could not load " << imgfile << std::endl;
		return -1;
	}
}

Thanks

Have you tried to see if you can open the file first ? Like this:

 std::ifstream test(imgfile, std::ios::binary);
    if (test.is_open()) {
        std::cerr << "File opens successfully: " << imgfile << std::endl;
        test.close();
    } else {
        std::cerr << "Cannot open file: " << imgfile << std::endl;
    }

That would tell you if you have access to the images, the path is correct, etc. If it works, it might be something happening in the nvgCreateImage() call instead.