protected void checkFlush(Texture sprite) {
        if (sprite == null)
            throw new NullPointerException("null texture");

        // we need to bind a different texture/type. this is
        // for convenience; ideally the user should order
        // their rendering wisely to minimize texture binds
        if (sprite != this.texture || idx >= maxIndex) {
            // apply the last texture
            flush();
            this.texture = sprite;
        }
    }