MCPcopy Create free account
hub / github.com/defold/defold / LoadPrototypeFromDDF

Function LoadPrototypeFromDDF

engine/particle/src/test/test_particle.cpp:289–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289bool LoadPrototypeFromDDF(const char* filename, dmParticle::HPrototype* prototype)
290{
291 char path[128];
292 dmTestUtil::MakeHostPathf(path, sizeof(path), "build/src/test/%s", filename);
293
294 const uint32_t MAX_FILE_SIZE = 4 * 1024;
295 unsigned char buffer[MAX_FILE_SIZE];
296 uint32_t file_size = 0;
297
298 FILE* f = fopen(path, "rb");
299 if (f)
300 {
301 file_size = fread(buffer, 1, MAX_FILE_SIZE, f);
302 fclose(f);
303 dmParticleDDF::ParticleFX* ddf = 0;
304 dmDDF::Result r = dmDDF::LoadMessage<dmParticleDDF::ParticleFX>(buffer, file_size, &ddf);
305 if (r != dmDDF::RESULT_OK)
306 {
307 dmLogError("Failed to load particle data");
308 return 0x0;
309 }
310 *prototype = dmParticle::NewPrototypeFromDDF(ddf);
311 return *prototype != 0x0;
312 }
313 else
314 {
315 dmLogWarning("Particle FX could not be loaded: %s.", path);
316 return false;
317 }
318}
319
320bool ReloadPrototype(const char* filename, dmParticle::HPrototype prototype)
321{

Callers 1

TEST_FFunction · 0.85

Calls 2

MakeHostPathfFunction · 0.85
NewPrototypeFromDDFFunction · 0.85

Tested by

no test coverage detected