aboutsummaryrefslogtreecommitdiff
path: root/dep/src/g3dlite/BinaryFormat.cpp
blob: d3991378f450fba89d1219d8197875bd2d56bbcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
 @file BinaryFormat.cpp
  @maintainer Morgan McGuire, http://graphics.cs.williams.edu

  @created 2005-06-10
  @edited  2005-06-10
 */

#include "G3D/BinaryFormat.h"

namespace G3D {

int32 byteSize(BinaryFormat f) {
    switch (f) {
    case BOOL8_BINFMT:
    case UINT8_BINFMT:
    case INT8_BINFMT:
        return 1;

    case UINT16_BINFMT:
    case INT16_BINFMT:
        return 2;

    case FLOAT16_BINFMT:
        return 2;

    case UINT32_BINFMT:
    case INT32_BINFMT:
    case FLOAT32_BINFMT:
        return 4;

    case FLOAT64_BINFMT:
    case UINT64_BINFMT:
    case INT64_BINFMT:
        return 8;

    case INT128_BINFMT:
    case UINT128_BINFMT:
        return 16;

    case VECTOR2_BINFMT:
        return 2 * 4;

    case VECTOR2INT16_BINFMT:
        return 2 * 2;

    case VECTOR3_BINFMT:
        return 3 * 4;

    case VECTOR3INT16_BINFMT:
        return 3 * 2;

    case VECTOR4_BINFMT:
        return 4 * 4;

    case VECTOR4INT16_BINFMT:
        return 4 * 4;

    case COLOR3_BINFMT:
        return 3 * 4;

    case COLOR3UINT8_BINFMT:
        return 3 * 1;

    case COLOR3INT16_BINFMT:
        return 3 * 2;

    case COLOR4_BINFMT:
        return 4 * 4;

    case COLOR4UINT8_BINFMT:
        return 4 * 1;

    case COLOR4INT16_BINFMT:
        return 4 * 2;

    default:
        return -1;
    }
}
}