Changeset 214
- Timestamp:
- 09/09/13 20:48:38 (12 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gl/gl_enum.hh
r70 r214 13 13 #define NV_GL_ENUM_HH 14 14 15 #include <nv/math.hh> 15 16 #include <nv/interface/clear_state.hh> 16 17 #include <nv/interface/render_state.hh> … … 18 19 #include <nv/interface/texture2d.hh> 19 20 #include <nv/interface/context.hh> 20 #include <nv/types.hh>21 21 22 22 namespace nv -
trunk/nv/interface/clear_state.hh
r121 r214 15 15 16 16 #include <nv/common.hh> 17 #include <nv/ types.hh>17 #include <nv/math.hh> 18 18 19 19 namespace nv -
trunk/nv/interface/mesh.hh
r148 r214 16 16 #include <nv/common.hh> 17 17 #include <nv/string.hh> 18 #include <nv/ types.hh>18 #include <nv/math.hh> 19 19 #include <nv/interface/context.hh> 20 20 #include <unordered_map> -
trunk/nv/interface/program.hh
r161 r214 18 18 #include <nv/common.hh> 19 19 #include <nv/string.hh> 20 #include <nv/ types.hh>20 #include <nv/math.hh> 21 21 22 22 namespace nv -
trunk/nv/interface/render_state.hh
r110 r214 15 15 16 16 #include <nv/common.hh> 17 #include <nv/ types.hh>17 #include <nv/math.hh> 18 18 #include <nv/interface/clear_state.hh> 19 19 #include <nv/string.hh> -
trunk/nv/interface/texture2d.hh
r121 r214 14 14 15 15 #include <nv/common.hh> 16 #include <nv/ types.hh>16 #include <nv/math.hh> 17 17 18 18 namespace nv -
trunk/nv/interface/vertex_buffer.hh
r155 r214 14 14 15 15 #include <nv/common.hh> 16 #include <nv/ types.hh>16 #include <nv/math.hh> 17 17 #include <unordered_map> 18 18 #include <string> -
trunk/nv/io_event.hh
r184 r214 15 15 16 16 #include <nv/common.hh> 17 #include <nv/types.hh>18 17 19 18 namespace nv -
trunk/nv/math.hh
r190 r214 8 8 #define NV_MATH_HH 9 9 10 #include <nv/common.hh> 11 10 12 #if NV_COMPILER == NV_GNUC 11 13 #pragma GCC system_header … … 14 16 #endif 15 17 16 #include <nv/common.hh>17 18 #include <glm/glm.hpp> 18 19 #include <glm/gtc/matrix_transform.hpp> … … 75 76 using glm::min; 76 77 78 enum datatype 79 { 80 INT, 81 BYTE, 82 SHORT, 83 UINT, 84 UBYTE, 85 USHORT, 86 FLOAT, 87 FLOAT_VECTOR_2, 88 FLOAT_VECTOR_3, 89 FLOAT_VECTOR_4, 90 FLOAT_MATRIX_2, 91 FLOAT_MATRIX_3, 92 FLOAT_MATRIX_4, 93 INT_VECTOR_2, 94 INT_VECTOR_3, 95 INT_VECTOR_4, 96 // unsupported gl conversion, remove? 97 BYTE_VECTOR_2, 98 BYTE_VECTOR_3, 99 BYTE_VECTOR_4, 100 }; 101 102 template < datatype EnumType > struct enum_to_type {}; 103 104 template <> struct enum_to_type< INT > { typedef int type; }; 105 template <> struct enum_to_type< UINT > { typedef unsigned int type; }; 106 template <> struct enum_to_type< SHORT > { typedef short type; }; 107 template <> struct enum_to_type< USHORT >{ typedef unsigned short type; }; 108 template <> struct enum_to_type< BYTE > { typedef char type; }; 109 template <> struct enum_to_type< UBYTE > { typedef unsigned char type; }; 110 template <> struct enum_to_type< FLOAT > { typedef f32 type; }; 111 112 template <> struct enum_to_type< FLOAT_VECTOR_2 > { typedef vec2 type; }; 113 template <> struct enum_to_type< FLOAT_VECTOR_3 > { typedef vec3 type; }; 114 template <> struct enum_to_type< FLOAT_VECTOR_4 > { typedef vec4 type; }; 115 116 template <> struct enum_to_type< INT_VECTOR_2 > { typedef ivec2 type; }; 117 template <> struct enum_to_type< INT_VECTOR_3 > { typedef ivec3 type; }; 118 template <> struct enum_to_type< INT_VECTOR_4 > { typedef ivec4 type; }; 119 120 template <> struct enum_to_type< BYTE_VECTOR_2 > { typedef i8vec2 type; }; 121 template <> struct enum_to_type< BYTE_VECTOR_3 > { typedef i8vec3 type; }; 122 template <> struct enum_to_type< BYTE_VECTOR_4 > { typedef i8vec4 type; }; 123 124 template <> struct enum_to_type< FLOAT_MATRIX_2 > { typedef mat2 type; }; 125 template <> struct enum_to_type< FLOAT_MATRIX_3 > { typedef mat3 type; }; 126 template <> struct enum_to_type< FLOAT_MATRIX_4 > { typedef mat4 type; }; 127 128 template < typename TYPE > struct type_to_enum {}; 129 130 template <> struct type_to_enum< long > { static const datatype type = INT; }; 131 template <> struct type_to_enum< unsigned long > { static const datatype type = UINT; }; 132 template <> struct type_to_enum< int > { static const datatype type = INT; }; 133 template <> struct type_to_enum< unsigned int > { static const datatype type = UINT; }; 134 template <> struct type_to_enum< short > { static const datatype type = SHORT; }; 135 template <> struct type_to_enum< unsigned short >{ static const datatype type = USHORT; }; 136 template <> struct type_to_enum< char > { static const datatype type = BYTE; }; 137 template <> struct type_to_enum< signed char > { static const datatype type = BYTE; }; 138 template <> struct type_to_enum< unsigned char > { static const datatype type = UBYTE; }; 139 template <> struct type_to_enum< f32 > { static const datatype type = FLOAT; }; 140 141 template <> struct type_to_enum< vec2 > { static const datatype type = FLOAT_VECTOR_2; }; 142 template <> struct type_to_enum< vec3 > { static const datatype type = FLOAT_VECTOR_3; }; 143 template <> struct type_to_enum< vec4 > { static const datatype type = FLOAT_VECTOR_4; }; 144 145 template <> struct type_to_enum< ivec2 > { static const datatype type = INT_VECTOR_2; }; 146 template <> struct type_to_enum< ivec3 > { static const datatype type = INT_VECTOR_3; }; 147 template <> struct type_to_enum< ivec4 > { static const datatype type = INT_VECTOR_4; }; 148 149 template <> struct type_to_enum< i8vec2 > { static const datatype type = BYTE_VECTOR_2; }; 150 template <> struct type_to_enum< i8vec3 > { static const datatype type = BYTE_VECTOR_3; }; 151 template <> struct type_to_enum< i8vec4 > { static const datatype type = BYTE_VECTOR_4; }; 152 153 template <> struct type_to_enum< mat2 > { static const datatype type = FLOAT_MATRIX_2; }; 154 template <> struct type_to_enum< mat3 > { static const datatype type = FLOAT_MATRIX_3; }; 155 template <> struct type_to_enum< mat4 > { static const datatype type = FLOAT_MATRIX_4; }; 156 157 77 158 } // namespace nv 78 159 -
trunk/nv/type_traits.hh
r211 r214 181 181 }; 182 182 183 template<typename T> 184 struct is_container 185 { 186 private: 187 typedef char yes; 188 typedef struct { char array[2]; } no; 189 template<typename C> static yes test(typename C::iterator*); 190 template<typename C> static no test(...); 191 public: 192 static const bool value = sizeof(test<T>(0)) == sizeof(yes); 193 }; 194 195 template<> 196 struct is_container< std::string > { 197 static const bool value = false; 198 }; 199 200 template <typename TYPE> 201 void construct_object(void* object) 202 { 203 new (object) TYPE; 204 } 205 template <typename TYPE> 206 void destroy_object(void* object) 207 { 208 ((TYPE*)object)->TYPE::~TYPE(); 209 } 183 210 } 184 211 -
trunk/nv/types.hh
r190 r214 9 9 #include <nv/math.hh> 10 10 #include <nv/object.hh> 11 #include < type_traits>11 #include <nv/type_traits.hh> 12 12 #include <typeinfo> 13 13 #include <typeindex> … … 20 20 namespace nv 21 21 { 22 enum datatype 23 { 24 INT, 25 BYTE, 26 SHORT, 27 UINT, 28 UBYTE, 29 USHORT, 30 FLOAT, 31 FLOAT_VECTOR_2, 32 FLOAT_VECTOR_3, 33 FLOAT_VECTOR_4, 34 FLOAT_MATRIX_2, 35 FLOAT_MATRIX_3, 36 FLOAT_MATRIX_4, 37 INT_VECTOR_2, 38 INT_VECTOR_3, 39 INT_VECTOR_4, 40 // unsupported gl conversion, remove? 41 BYTE_VECTOR_2, 42 BYTE_VECTOR_3, 43 BYTE_VECTOR_4, 44 }; 45 46 template < datatype EnumType > struct enum_to_type {}; 47 48 template <> struct enum_to_type< INT > { typedef int type; }; 49 template <> struct enum_to_type< UINT > { typedef unsigned int type; }; 50 template <> struct enum_to_type< SHORT > { typedef short type; }; 51 template <> struct enum_to_type< USHORT >{ typedef unsigned short type; }; 52 template <> struct enum_to_type< BYTE > { typedef char type; }; 53 template <> struct enum_to_type< UBYTE > { typedef unsigned char type; }; 54 template <> struct enum_to_type< FLOAT > { typedef f32 type; }; 55 56 template <> struct enum_to_type< FLOAT_VECTOR_2 > { typedef vec2 type; }; 57 template <> struct enum_to_type< FLOAT_VECTOR_3 > { typedef vec3 type; }; 58 template <> struct enum_to_type< FLOAT_VECTOR_4 > { typedef vec4 type; }; 59 60 template <> struct enum_to_type< INT_VECTOR_2 > { typedef ivec2 type; }; 61 template <> struct enum_to_type< INT_VECTOR_3 > { typedef ivec3 type; }; 62 template <> struct enum_to_type< INT_VECTOR_4 > { typedef ivec4 type; }; 63 64 template <> struct enum_to_type< BYTE_VECTOR_2 > { typedef i8vec2 type; }; 65 template <> struct enum_to_type< BYTE_VECTOR_3 > { typedef i8vec3 type; }; 66 template <> struct enum_to_type< BYTE_VECTOR_4 > { typedef i8vec4 type; }; 67 68 template <> struct enum_to_type< FLOAT_MATRIX_2 > { typedef mat2 type; }; 69 template <> struct enum_to_type< FLOAT_MATRIX_3 > { typedef mat3 type; }; 70 template <> struct enum_to_type< FLOAT_MATRIX_4 > { typedef mat4 type; }; 71 72 template < typename TYPE > struct type_to_enum {}; 73 74 template <> struct type_to_enum< long > { static const datatype type = INT; }; 75 template <> struct type_to_enum< unsigned long > { static const datatype type = UINT; }; 76 template <> struct type_to_enum< int > { static const datatype type = INT; }; 77 template <> struct type_to_enum< unsigned int > { static const datatype type = UINT; }; 78 template <> struct type_to_enum< short > { static const datatype type = SHORT; }; 79 template <> struct type_to_enum< unsigned short >{ static const datatype type = USHORT; }; 80 template <> struct type_to_enum< char > { static const datatype type = BYTE; }; 81 template <> struct type_to_enum< signed char > { static const datatype type = BYTE; }; 82 template <> struct type_to_enum< unsigned char > { static const datatype type = UBYTE; }; 83 template <> struct type_to_enum< f32 > { static const datatype type = FLOAT; }; 84 85 template <> struct type_to_enum< vec2 > { static const datatype type = FLOAT_VECTOR_2; }; 86 template <> struct type_to_enum< vec3 > { static const datatype type = FLOAT_VECTOR_3; }; 87 template <> struct type_to_enum< vec4 > { static const datatype type = FLOAT_VECTOR_4; }; 88 89 template <> struct type_to_enum< ivec2 > { static const datatype type = INT_VECTOR_2; }; 90 template <> struct type_to_enum< ivec3 > { static const datatype type = INT_VECTOR_3; }; 91 template <> struct type_to_enum< ivec4 > { static const datatype type = INT_VECTOR_4; }; 92 93 template <> struct type_to_enum< i8vec2 > { static const datatype type = BYTE_VECTOR_2; }; 94 template <> struct type_to_enum< i8vec3 > { static const datatype type = BYTE_VECTOR_3; }; 95 template <> struct type_to_enum< i8vec4 > { static const datatype type = BYTE_VECTOR_4; }; 96 97 template <> struct type_to_enum< mat2 > { static const datatype type = FLOAT_MATRIX_2; }; 98 template <> struct type_to_enum< mat3 > { static const datatype type = FLOAT_MATRIX_3; }; 99 template <> struct type_to_enum< mat4 > { static const datatype type = FLOAT_MATRIX_4; }; 100 101 template<typename T> 102 struct is_container 103 { 104 private: 105 typedef char yes; 106 typedef struct { char array[2]; } no; 107 template<typename C> static yes test(typename C::iterator*); 108 template<typename C> static no test(...); 109 public: 110 static const bool value = sizeof(test<T>(0)) == sizeof(yes); 111 }; 112 113 template<> 114 struct is_container< std::string > { 115 static const bool value = false; 116 }; 117 118 template <typename TYPE> void ConstructObject(void* object) 119 { 120 // Use placement new to call the constructor 121 new (object) TYPE; 122 } 123 template <typename TYPE> void DestructObject(void* object) 124 { 125 // Explicit call of the destructor 126 ((TYPE*)object)->TYPE::~TYPE(); 127 } 128 22 129 23 struct type_entry; 130 24 … … 255 149 i_type->size = sizeof(TYPE); 256 150 257 i_type->constructor = ConstructObject<TYPE>;258 i_type->destructor = DestructObject<TYPE>;151 i_type->constructor = construct_object<TYPE>; 152 i_type->destructor = destroy_object<TYPE>; 259 153 260 154 m_name_types[name] = i_type; -
trunk/src/io_event.cc
r184 r214 6 6 7 7 #include "nv/io_event.hh" 8 9 #include <nv/types.hh> 8 10 9 11 using namespace nv; -
trunk/tests/cachebuf_test/nv_cachebuf_test.cc
r161 r214 12 12 #include <glm/gtc/type_ptr.hpp> 13 13 #include <nv/string.hh> 14 #include <nv/types.hh>15 14 #include <nv/interface/mesh.hh> 16 15 #include <cstdlib> // rand -
trunk/tests/lualib_test/init.lua
r52 r214 1 print "hello world from Lua!" 2 hello( "Hello" ) -
trunk/tests/lualib_test/lualib_test.cc
r213 r214 5 5 #include <nv/lua/lua_glm.hh> 6 6 #include <nv/logger.hh> 7 #include <nv/ types.hh>7 #include <nv/math.hh> 8 8 #include <nv/object.hh> 9 9 #include <string> -
trunk/tests/md2_test/md2_test.cc
r189 r214 18 18 #include <nv/time.hh> 19 19 #include <nv/string.hh> 20 #include <nv/types.hh>21 20 #include <nv/interface/mesh.hh> 22 21 #include <glm/gtx/rotate_vector.hpp> -
trunk/tests/objload_test/objload_test.cc
r139 r214 13 13 #include <nv/math.hh> 14 14 #include <nv/string.hh> 15 #include <nv/types.hh>16 15 #include <nv/interface/mesh.hh> 17 16 -
trunk/tests/render_test/rl.cc
r121 r214 10 10 #include <nv/math.hh> 11 11 #include <nv/string.hh> 12 #include <nv/types.hh>13 12 #include <nv/interface/mesh.hh> 14 13
Note: See TracChangeset
for help on using the changeset viewer.