static void get_current_texture(GLenum target, GLint* tex) {
   switch (target) {
#define GET_TEXTURE(a) \
   case GL_TEXTURE_ ## a: \
      glGetIntegerv(GL_TEXTURE_BINDING_ ## a, tex); return
   GET_TEXTURE(1D);
   GET_TEXTURE(2D);
   GET_TEXTURE(3D);
   GET_TEXTURE(1D_ARRAY);
   GET_TEXTURE(2D_ARRAY);
   GET_TEXTURE(RECTANGLE);
   GET_TEXTURE(CUBE_MAP);
   GET_TEXTURE(CUBE_MAP_ARRAY);
   GET_TEXTURE(BUFFER);
   GET_TEXTURE(2D_MULTISAMPLE);
   GET_TEXTURE(2D_MULTISAMPLE_ARRAY);
#undef GET_TEXTURE
   default:
      vrend_printf("Unknown texture target %x\n", target);
   }
}
static void get_current_texture(GLenum target, GLint* tex) {
   switch (target) {
#define GET_TEXTURE(a) \
   case GL_TEXTURE_ ## a: \
      glGetIntegerv(GL_TEXTURE_BINDING_ ## a, tex); return
   GET_TEXTURE(1D);
   GET_TEXTURE(2D);
   GET_TEXTURE(3D);
   GET_TEXTURE(1D_ARRAY);
   GET_TEXTURE(2D_ARRAY);
   GET_TEXTURE(RECTANGLE);
   GET_TEXTURE(CUBE_MAP);
   GET_TEXTURE(CUBE_MAP_ARRAY);
   GET_TEXTURE(BUFFER);
   GET_TEXTURE(2D_MULTISAMPLE);
   GET_TEXTURE(2D_MULTISAMPLE_ARRAY);
#undef GET_TEXTURE
   default:
      vrend_printf("Unknown texture target %x\n", target);
   }
}