void graphics_ParticleSystem_new(graphics_ParticleSystem *ps, graphics_Image const *texture, size_t buffer) { ps->sizes = 0; ps->colors = 0; ps->quads = 0; ps->active = false; graphics_Batch_new(&ps->batch, texture, buffer, graphics_BatchUsage_stream); graphics_ParticleSystem_setBufferSize(ps, buffer); graphics_ParticleSystem_reset(ps); graphics_ParticleSystem_setTexture(ps, texture); graphics_ParticleSystem_setInsertMode(ps, graphics_ParticleInsertMode_top); graphics_ParticleSystem_setEmissionRate(ps, 0.0f); graphics_ParticleSystem_setPosition(ps, 0.0f, 0.0f); graphics_ParticleSystem_setAreaSpread(ps, graphics_AreaSpreadDistribution_none, 0.0f, 0.0f); graphics_ParticleSystem_setEmitterLifetime(ps, -1.0f); graphics_ParticleSystem_setParticleLifetime(ps, 0.0f, 0.0f); graphics_ParticleSystem_setDirection(ps, 0.0f); graphics_ParticleSystem_setSpread(ps, 0.0f); graphics_ParticleSystem_setSpeed(ps, 0.0f, 0.0f); graphics_ParticleSystem_setLinearAcceleration(ps, 0.0f, 0.0f, 0.0f, 0.0f); graphics_ParticleSystem_setRadialAcceleration(ps, 0.0f, 0.0f); graphics_ParticleSystem_setTangentialAcceleration(ps, 0.0f, 0.0f); graphics_ParticleSystem_setLinearDamping(ps, 0.0f, 0.0f); graphics_ParticleSystem_setSizes(ps, 1, &defaultSize); graphics_ParticleSystem_setSizeVariation(ps, 0.0f); graphics_ParticleSystem_setRotation(ps, 0.0f, 0.0f); graphics_ParticleSystem_setSpin(ps, 0.0f, 0.0f); graphics_ParticleSystem_setSpinVariation(ps, 0.0f); graphics_ParticleSystem_setOffset(ps, ((float)texture->width) * 0.5f, ((float)texture->height) * 0.5f); graphics_ParticleSystem_setColors(ps, 1, &defaultColor); graphics_ParticleSystem_setQuads(ps, 1, &defaultQuadPtr); graphics_ParticleSystem_setRelativeRotation(ps, false); }
int l_graphics_newSpriteBatch(lua_State* state) { l_graphics_Image const* image = l_graphics_toImage(state, 1); int count = luaL_optnumber(state, 2, 128); l_graphics_Batch* batch = lua_newuserdata(state, sizeof(l_graphics_Batch)); graphics_Batch_new(&batch->batch, &image->image, count, graphics_BatchUsage_static); lua_pushvalue(state, 1); batch->textureRef = luaL_ref(state, LUA_REGISTRYINDEX); lua_rawgeti(state, LUA_REGISTRYINDEX, moduleData.batchMT); lua_setmetatable(state, -2); return 1; }