| 1 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield |
|---|
| 2 | * |
|---|
| 3 | * This library is open source and may be redistributed and/or modified under |
|---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
|---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
|---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
|---|
| 7 | * |
|---|
| 8 | * This library is distributed in the hope that it will be useful, |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | * OpenSceneGraph Public License for more details. |
|---|
| 12 | */ |
|---|
| 13 | // Written by Wang Rui, (C) 2010 |
|---|
| 14 | |
|---|
| 15 | #ifndef OSGDB_DATATYPES |
|---|
| 16 | #define OSGDB_DATATYPES |
|---|
| 17 | |
|---|
| 18 | #include <string> |
|---|
| 19 | #include <osg/GL> |
|---|
| 20 | |
|---|
| 21 | namespace osgDB |
|---|
| 22 | { |
|---|
| 23 | |
|---|
| 24 | // OSG Header (MD5, 16Bit) |
|---|
| 25 | #define OSG_HEADER_LOW 0x6C910EA1 |
|---|
| 26 | #define OSG_HEADER_HIGH 0x1AFB4545 |
|---|
| 27 | |
|---|
| 28 | // Reader/writer plugin version |
|---|
| 29 | const unsigned int PLUGIN_VERSION = 2; |
|---|
| 30 | |
|---|
| 31 | const int BOOL_SIZE = 1; |
|---|
| 32 | const int CHAR_SIZE = 1; |
|---|
| 33 | const int SHORT_SIZE = 2; |
|---|
| 34 | const int INT_SIZE = 4; |
|---|
| 35 | const int LONG_SIZE = 4; |
|---|
| 36 | const int FLOAT_SIZE = 4; |
|---|
| 37 | const int DOUBLE_SIZE = 8; |
|---|
| 38 | const int GLENUM_SIZE = 4; |
|---|
| 39 | |
|---|
| 40 | const int ID_BYTE_ARRAY = 0; |
|---|
| 41 | const int ID_UBYTE_ARRAY = 1; |
|---|
| 42 | const int ID_SHORT_ARRAY = 2; |
|---|
| 43 | const int ID_USHORT_ARRAY = 3; |
|---|
| 44 | const int ID_INT_ARRAY = 4; |
|---|
| 45 | const int ID_UINT_ARRAY = 5; |
|---|
| 46 | const int ID_FLOAT_ARRAY = 6; |
|---|
| 47 | const int ID_DOUBLE_ARRAY = 7; |
|---|
| 48 | const int ID_VEC2B_ARRAY = 8; |
|---|
| 49 | const int ID_VEC3B_ARRAY = 9; |
|---|
| 50 | const int ID_VEC4B_ARRAY = 10; |
|---|
| 51 | const int ID_VEC4UB_ARRAY = 11; |
|---|
| 52 | const int ID_VEC2S_ARRAY = 12; |
|---|
| 53 | const int ID_VEC3S_ARRAY = 13; |
|---|
| 54 | const int ID_VEC4S_ARRAY = 14; |
|---|
| 55 | const int ID_VEC2_ARRAY = 15; |
|---|
| 56 | const int ID_VEC3_ARRAY = 16; |
|---|
| 57 | const int ID_VEC4_ARRAY = 17; |
|---|
| 58 | const int ID_VEC2D_ARRAY = 18; |
|---|
| 59 | const int ID_VEC3D_ARRAY = 19; |
|---|
| 60 | const int ID_VEC4D_ARRAY = 20; |
|---|
| 61 | |
|---|
| 62 | const int ID_DRAWARRAYS = 50; |
|---|
| 63 | const int ID_DRAWARRAY_LENGTH = 51; |
|---|
| 64 | const int ID_DRAWELEMENTS_UBYTE = 52; |
|---|
| 65 | const int ID_DRAWELEMENTS_USHORT = 53; |
|---|
| 66 | const int ID_DRAWELEMENTS_UINT = 54; |
|---|
| 67 | |
|---|
| 68 | // Used by BEGIN_BRACKET and END_BRACKET |
|---|
| 69 | const int INDENT_VALUE = 2; |
|---|
| 70 | |
|---|
| 71 | // Used by the writeImage/readImage parameter |
|---|
| 72 | const int IMAGE_INLINE_DATA = 0; |
|---|
| 73 | const int IMAGE_INLINE_FILE = 1; |
|---|
| 74 | const int IMAGE_EXTERNAL = 2; |
|---|
| 75 | const int IMAGE_WRITE_OUT = 3; |
|---|
| 76 | |
|---|
| 77 | struct ObjectGLenum |
|---|
| 78 | { |
|---|
| 79 | ObjectGLenum( GLenum value=0 ) : _value(value) {} |
|---|
| 80 | ObjectGLenum( const ObjectGLenum& copy ) : _value(copy._value) {} |
|---|
| 81 | void set( GLenum e ) { _value = e; } |
|---|
| 82 | GLenum get() const { return _value; } |
|---|
| 83 | GLenum _value; |
|---|
| 84 | }; |
|---|
| 85 | #define GLENUM(value) osgDB::ObjectGLenum(value) |
|---|
| 86 | #define DEF_GLENUM(var) osgDB::ObjectGLenum var; |
|---|
| 87 | |
|---|
| 88 | class ObjectProperty |
|---|
| 89 | { |
|---|
| 90 | public: |
|---|
| 91 | ObjectProperty( const char* name, int value=0, bool useMap=false ) |
|---|
| 92 | : _name(name), _value(value), _mapProperty(useMap) {} |
|---|
| 93 | |
|---|
| 94 | ObjectProperty( const ObjectProperty& copy ) |
|---|
| 95 | : _name(copy._name), _value(copy._value), _mapProperty(copy._mapProperty) {} |
|---|
| 96 | |
|---|
| 97 | ObjectProperty& proto( const char* name ) |
|---|
| 98 | { _name = name; return *this; } |
|---|
| 99 | |
|---|
| 100 | void set( int v ) { _value = v; } |
|---|
| 101 | int get() const { return _value; } |
|---|
| 102 | |
|---|
| 103 | std::string _name; |
|---|
| 104 | int _value; |
|---|
| 105 | bool _mapProperty; |
|---|
| 106 | |
|---|
| 107 | protected: |
|---|
| 108 | ObjectProperty():_value(0),_mapProperty(false) {} |
|---|
| 109 | }; |
|---|
| 110 | static ObjectProperty defaultProp(""); |
|---|
| 111 | |
|---|
| 112 | #define PROPERTY(name) defaultProp.proto(name) |
|---|
| 113 | #define MAPPEE(pairName, value) osgDB::ObjectProperty(#pairName, value, true) |
|---|
| 114 | #define DEF_PROPERTY(name, var) osgDB::ObjectProperty var(name); |
|---|
| 115 | #define DEF_MAPPEE(pairName, var) osgDB::ObjectProperty var(#pairName, 0, true); |
|---|
| 116 | |
|---|
| 117 | class ObjectMark |
|---|
| 118 | { |
|---|
| 119 | public: |
|---|
| 120 | ObjectMark( const char* name, int delta=0 ) |
|---|
| 121 | : _name(name), _indentDelta(delta) {} |
|---|
| 122 | |
|---|
| 123 | ObjectMark( const ObjectMark& copy ) |
|---|
| 124 | : _name(copy._name), _indentDelta(copy._indentDelta) {} |
|---|
| 125 | |
|---|
| 126 | std::string _name; |
|---|
| 127 | int _indentDelta; |
|---|
| 128 | |
|---|
| 129 | protected: |
|---|
| 130 | ObjectMark():_indentDelta(0) {} |
|---|
| 131 | }; |
|---|
| 132 | static ObjectMark BEGIN_BRACKET("{", +INDENT_VALUE); |
|---|
| 133 | static ObjectMark END_BRACKET ("}", -INDENT_VALUE); |
|---|
| 134 | |
|---|
| 135 | } |
|---|
| 136 | #endif |
|---|