GLenum get_gl_type(DataType type)
{
- const MappedType *ptr = lower_bound(type_map, type_map+type_map_size, type, type_compare);
- if(ptr->type!=type)
+ const MappedType *end = type_map+type_map_size;
+ const MappedType *ptr = lower_bound(type_map, end, type, type_compare);
+ if(ptr==end || ptr->type!=type)
throw invalid_argument("get_gl_type");
return ptr->gl_type;
}
+DataType from_gl_type(GLenum gl_type)
+{
+ for(unsigned i=0; i<type_map_size; ++i)
+ if(type_map[i].gl_type==gl_type)
+ return type_map[i].type;
+ throw invalid_argument("from_gl_type");
+}
+
+void require_type(DataType type)
+{
+ unsigned rows = ((type>>12)&3)+1;
+ unsigned cols = ((type>>14)&4)+1;
+ if(rows>1 && cols>1 && rows!=cols)
+ static Require _req(NV_non_square_matrices);
+ if((type&0x200) && get_type_size(type)/(rows*cols)==8)
+ static Require _req(ARB_gpu_shader_fp64);
+}
+
} // namespace GL
} // namespace Msp