void graphics_ParticleSystem_draw(graphics_ParticleSystem *ps, float x, float y, float r, float sx, float sy, float ox, float oy, float kx, float ky) { //printf("Drawing particle system, %d particles\n", ps->activeParticles); graphics_Batch *b = &ps->batch; //graphics_Batch_bind(b); graphics_Batch_clear(b); for(graphics_Particle *p = ps->pHead; p; p = p->next) { // TODO move the following back to the draw function! graphics_Quad const* q = ps->quads[p->quadIndex]; graphics_Batch_setColor(b, p->color.red, p->color.green, p->color.blue, p->color.alpha); graphics_Batch_add(b, q, p->position[0], p->position[1], p->angle, p->size, p->size, ps->offsetX, ps->offsetY, 0.0f, 0.0f); } graphics_Batch_flush(b); graphics_Batch_draw(&ps->batch, x, y, r, sx, sy, ox, oy, kx, ky); }
int l_graphics_SpriteBatch_setColor(lua_State* state) { l_assertType(state, 1, l_graphics_isBatch); l_graphics_Batch * batch = l_graphics_toBatch(state, 1); if(!lua_isnumber(state, 2)) { graphics_Batch_clearColor(&batch->batch); } else { float r = l_tools_toNumberOrError(state, 2); float g = l_tools_toNumberOrError(state, 3); float b = l_tools_toNumberOrError(state, 4); float a = luaL_optnumber(state, 5, 255); graphics_Batch_setColor(&batch->batch, r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); } return 0; }