subimages with gldrawPixels performance advince needed

This is my code:

void drawBox(unsigned int num, float x, float y){
  glPixelStorei(GL_UNPACK_SKIP_PIXELS, (num&0x3)*16);
  glPixelStorei(GL_UNPACK_SKIP_ROWS, (num>>2)*16);
  glDrawPixels(16,16,GL_RGB,GL_UNSIGNED_BYTE, picMap.Data);

It draws a subimage of a whole image(which is 4x4 images, with each image being 16x16 pixels), num specifies the image, and x,y specefies the position.

This func is run a lot of times in a close loop, and I’m wondering what’s the best way to optimise it.

Should I design so it isn’t drawing a subimage?
Would that help?

Or should I write to a local buffer, and then blit it off on the screen?

IDK wishes you Happy programming!

If you want speed, don’t use glDrawPixels. Upload you data into a texture and write it to the screen using an ortho projection.

Ok, thanks a lot.