added renderbuffer function and modified render function