]> git.tdb.fi Git - libs/gl.git/blobdiff - source/datatype.cpp
Add some files which got forgotten in earlier commits
[libs/gl.git] / source / datatype.cpp
diff --git a/source/datatype.cpp b/source/datatype.cpp
new file mode 100644 (file)
index 0000000..1def3ca
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdexcept>
+#include "datatype.h"
+
+using namespace std;
+
+namespace Msp {
+namespace GL {
+
+unsigned get_type_size(DataType type)
+{
+       switch(type)
+       {
+       case BYTE:
+       case UNSIGNED_BYTE: return 1;
+       case SHORT:
+       case UNSIGNED_SHORT:
+       case HALF_FLOAT: return 2;
+       case INT:
+       case UNSIGNED_INT:
+       case FLOAT: return 4;
+       default: throw invalid_argument("get_type_size");
+       }
+}
+
+} // namespace GL
+} // namespace Msp