- Timestamp:
- 05/28/15 10:21:10 (10 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/common.hh
r374 r376 4 4 // This file is part of NV Libraries. 5 5 // For conditions of distribution and use, see copyright notice in nv.hh 6 7 6 #ifndef NV_CORE_COMMON_HH 8 7 #define NV_CORE_COMMON_HH … … 68 67 69 68 // Platform specific settings. 70 #if NV_ PLATFORM == NV_WINDOWS69 #if NV_COMPILER == NV_MSVC 71 70 #ifdef _DEBUG 72 71 #define NV_DEBUG 1 … … 74 73 #define NV_DEBUG 0 75 74 #endif 76 #e ndif77 78 # if NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE79 # ifdef DEBUG75 #else 76 #ifdef NDEBUG 77 #define NV_DEBUG 0 78 #else 80 79 #define NV_DEBUG 1 81 #else82 #define NV_DEBUG 083 80 #endif 84 81 #endif … … 105 102 #endif 106 103 107 #if NV_COMPILER == NV_GNUC && NV_COMP_VER < 4 60108 #error "GCC 4. 6+ required!"104 #if NV_COMPILER == NV_GNUC && NV_COMP_VER < 480 105 #error "GCC 4.8+ required!" 109 106 #endif 110 107 … … 125 122 #endif 126 123 127 #include <cassert>128 129 124 #define NV_STRINGIZE_DETAIL(x) #x 130 125 #define NV_STRINGIZE(x) NV_STRINGIZE_DETAIL(x) 126 127 #if NV_COMPILER == NV_MSVC 128 #define NV_WIDE_DETAIL(x) L ## x 129 #define NV_WIDE(x) NV_WIDE_DETAIL(x) 130 #endif 131 131 132 132 #if NV_COMPILER == NV_MSVC … … 134 134 #define NV_ALIGN(value) __declspec(align(value)) 135 135 #define NV_ALIGNED_STRUCT(value) __declspec(align(value)) struct 136 #define NV_NOALIAS __declspec(noalias) 136 137 #define NV_RESTRICT __declspec(restrict) 137 138 #define NV_RESTRICT_VAR __restrict 138 139 #define NV_NOEXCEPT throw() 139 140 #define NV_ALIGN_OF(type) __alignof(type) 141 #if NV_ARCHITECTURE == NV_64BIT 142 #define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) ) 143 #else // NV_32BIT 144 #define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) 145 #endif 140 146 //#define NV_CONSTEXPR 141 147 #elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG … … 147 153 #define NV_NOEXCEPT noexcept 148 154 #define NV_ALIGN_OF(type) alignof(type) 155 #define NV_OFFSET_OF(obj, m) __builtin_offsetof(obj, m) 149 156 //#define NV_CONSTEXPR constexpr 150 157 #else 151 #define NV_DEPRECATED(func) func 152 #define NV_ALIGN(value) 153 #define NV_ALIGNED_STRUCT(value) struct 154 #define NV_RESTRICT 155 #define NV_RESTRICT_VAR 156 #define NV_NOEXCEPT 157 #define NV_ALIGN_OF 158 //#define NV_CONSTEXPR 158 #error "Unknown compiler, cannot proceed!" 159 159 #endif 160 160 161 161 #define NV_UNUSED(x) (void)(x) 162 #define NV_ASSERT(cond, msg) assert( (cond) && msg )163 162 #define NV_THROW(eobj, ...) { \ 164 163 NV_LOG_ERROR( __FILE__ " line " NV_STRINGIZE(__LINE__) " - exception thrown - " #eobj ); \ … … 184 183 } 185 184 186 using ::size_t; // typedef decltype( sizeof( int ) ) size_t; 187 using ::ptrdiff_t; 185 using size_t = decltype( sizeof(0) ); 186 using ptrdiff_t = decltype((int*)0 - (int*)0); 187 188 using nullptr_t = decltype( nullptr ); 188 189 189 190 // Typedefs for fixed size types. … … 196 197 typedef unsigned int uint32; 197 198 198 #if NV_COMPILER == NV_MSVC199 typedef signed __int64 sint64;200 typedef unsigned __int64 uint64;201 #else202 199 typedef signed long long sint64; 203 200 typedef unsigned long long uint64; 204 #endif 201 205 202 typedef unsigned char uchar8; 206 203 typedef unsigned short uchar16; … … 242 239 typedef T value_type; 243 240 typedef integral_constant<T, VALUE> type; 244 NV_CONSTEXPR operator value_type() const { return ( value ); } 245 }; 246 247 typedef integral_constant<bool, true> true_type; 248 typedef integral_constant<bool, false> false_type; 241 NV_CONSTEXPR operator value_type() const NV_NOEXCEPT { return ( value ); } 242 NV_CONSTEXPR value_type operator()() const NV_NOEXCEPT { return value; } 243 }; 244 245 // TODO: Propagate 246 template< bool B > 247 using bool_constant = integral_constant < bool, B > ; 248 249 typedef bool_constant<true> true_type; 250 typedef bool_constant<false> false_type; 249 251 250 252 template< bool TEST, typename T = void> … … 313 315 static_assert( sizeof( nv::f64 ) == 8, "float64 size isn't 8 bytes" ); 314 316 317 #include <nv/stl/assert.hh> 315 318 316 319 #endif // NV_CORE_COMMON_HH 320 -
trunk/nv/interface/animation_key.hh
r368 r376 120 120 typedef decltype( KEY::time ) value_type; 121 121 static const datatype etype = type_to_enum< decltype( KEY::time ) >::type; 122 static const int offset = offsetof( KEY, time );122 static const int offset = NV_OFFSET_OF( KEY, time ); 123 123 }; 124 124 … … 128 128 typedef decltype( KEY::position ) value_type; 129 129 static const datatype etype = type_to_enum< decltype( KEY::position ) >::type; 130 static const int offset = offsetof( KEY, position );130 static const int offset = NV_OFFSET_OF( KEY, position ); 131 131 static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor ) 132 132 { … … 140 140 typedef decltype( KEY::rotation ) value_type; 141 141 static const datatype etype = type_to_enum< decltype( KEY::rotation ) >::type; 142 static const int offset = offsetof( KEY, rotation );142 static const int offset = NV_OFFSET_OF( KEY, rotation ); 143 143 static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor ) 144 144 { … … 152 152 typedef decltype( KEY::scale ) value_type; 153 153 static const datatype etype = type_to_enum< decltype( KEY::scale ) >::type; 154 static const int offset = offsetof( KEY, scale );154 static const int offset = NV_OFFSET_OF( KEY, scale ); 155 155 static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor ) 156 156 { … … 164 164 typedef decltype( KEY::tform ) value_type; 165 165 static const datatype etype = type_to_enum< decltype( KEY::tform ) >::type; 166 static const int offset = offsetof( KEY, tform );166 static const int offset = NV_OFFSET_OF( KEY, tform ); 167 167 static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor ) 168 168 { … … 173 173 174 174 template < typename KEY, animation_slot SLOT > 175 struct key_has_slot : public detail::key_has_slot_impl< KEY, SLOT>175 struct key_has_slot : bool_constant< detail::key_has_slot_impl< KEY, SLOT >::value > 176 176 { 177 177 }; -
trunk/nv/interface/interpolation_template.hh
r374 r376 32 32 void interpolate_key( KEY& key, const KEY& k1, const KEY& k2, float factor ) 33 33 { 34 interpolate_slot< KEY, animation_slot::POSITION >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::POSITION >::value>() );35 interpolate_slot< KEY, animation_slot::ROTATION >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::ROTATION >::value>() );36 interpolate_slot< KEY, animation_slot::SCALE >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::SCALE >::value>() );37 interpolate_slot< KEY, animation_slot::TFORM >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::TFORM >::value>() );34 interpolate_slot< KEY, animation_slot::POSITION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::POSITION >() ); 35 interpolate_slot< KEY, animation_slot::ROTATION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::ROTATION >() ); 36 interpolate_slot< KEY, animation_slot::SCALE >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::SCALE >() ); 37 interpolate_slot< KEY, animation_slot::TFORM >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::TFORM >() ); 38 38 } 39 39 … … 135 135 static_assert( key_has_slot< KEY, animation_slot::TFORM >::value == false, "key!"); 136 136 return extract_matrix_prs( k, 137 integral_constant< bool, key_has_slot< KEY, animation_slot::POSITION >::value>(),138 integral_constant< bool, key_has_slot< KEY, animation_slot::ROTATION >::value>(),139 integral_constant< bool, key_has_slot< KEY, animation_slot::SCALE >::value>()137 key_has_slot< KEY, animation_slot::POSITION >(), 138 key_has_slot< KEY, animation_slot::ROTATION >(), 139 key_has_slot< KEY, animation_slot::SCALE >() 140 140 ); 141 141 } … … 156 156 static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!"); 157 157 return extract_transform_pr_impl( k, 158 integral_constant< bool,key_has_slot< KEY, animation_slot::POSITION >::value >(),159 integral_constant< bool, key_has_slot< KEY, animation_slot::ROTATION >::value >()158 key_has_slot< KEY, animation_slot::POSITION >::value >(), 159 key_has_slot< KEY, animation_slot::ROTATION >::value >() 160 160 ); 161 161 } … … 165 165 mat4 extract_matrix( const KEY& k ) 166 166 { 167 return detail::extract_matrix_impl( k, integral_constant< bool, key_has_slot< KEY, animation_slot::TFORM >::value>() );167 return detail::extract_matrix_impl( k, key_has_slot< KEY, animation_slot::TFORM >() ); 168 168 } 169 169 … … 171 171 transform extract_transform( const KEY& k ) 172 172 { 173 return detail::extract_transform_impl( k, integral_constant< bool, key_has_slot< KEY, animation_slot::TFORM >::value>() );173 return detail::extract_transform_impl( k, key_has_slot< KEY, animation_slot::TFORM >() ); 174 174 } 175 175 -
trunk/nv/interface/vertex.hh
r368 r376 164 164 typedef decltype( VT::position ) value_type; 165 165 static const datatype etype = type_to_enum< decltype( VT::position ) >::type; 166 static const int offset = offsetof( VT, position );166 static const int offset = NV_OFFSET_OF( VT, position ); 167 167 }; 168 168 … … 172 172 typedef decltype( VT::texcoord ) value_type; 173 173 static const datatype etype = type_to_enum< decltype( VT::texcoord ) >::type; 174 static const int offset = offsetof( VT, texcoord );174 static const int offset = NV_OFFSET_OF( VT, texcoord ); 175 175 }; 176 176 … … 180 180 typedef decltype( VT::normal ) value_type; 181 181 static const datatype etype = type_to_enum< decltype( VT::normal ) >::type; 182 static const int offset = offsetof( VT, normal );182 static const int offset = NV_OFFSET_OF( VT, normal ); 183 183 }; 184 184 … … 188 188 typedef decltype( VT::tangent ) value_type; 189 189 static const datatype etype = type_to_enum< decltype( VT::tangent ) >::type; 190 static const int offset = offsetof( VT, tangent );190 static const int offset = NV_OFFSET_OF( VT, tangent ); 191 191 }; 192 192 … … 196 196 typedef decltype( VT::boneindex ) value_type; 197 197 static const datatype etype = type_to_enum< decltype( VT::boneindex ) >::type; 198 static const int offset = offsetof( VT, boneindex );198 static const int offset = NV_OFFSET_OF( VT, boneindex ); 199 199 }; 200 200 … … 204 204 typedef decltype( VT::boneweight ) value_type; 205 205 static const datatype etype = type_to_enum< decltype( VT::boneweight ) >::type; 206 static const int offset = offsetof( VT, boneweight );206 static const int offset = NV_OFFSET_OF( VT, boneweight ); 207 207 }; 208 208 … … 212 212 typedef decltype( VT::color ) value_type; 213 213 static const datatype etype = type_to_enum< decltype( VT::color ) >::type; 214 static const int offset = offsetof( VT, color );214 static const int offset = NV_OFFSET_OF( VT, color ); 215 215 }; 216 216 -
trunk/nv/lib/curses.hh
r374 r376 29 29 #endif 30 30 31 // for va_list 32 #include <stdarg.h> 31 33 #ifdef CURSES_PDC_WIDE 32 34 #include <wchar.h> -
trunk/nv/lib/detail/wgl_functions.inc
r245 r376 12 12 NV_GL_FUN_REN( BOOL, wglRealizeLayerPalette, dynwglRealizeLayerPalette,(HDC, int, BOOL) ); 13 13 NV_GL_FUN_REN( BOOL, wglSwapLayerBuffers, dynwglSwapLayerBuffers, (HDC, UINT) ); 14 NV_GL_FUN_REN( DWORD, wglSwapMultipleBuffers, dynwglSwapMultipleBuffers, (UINT, CONST WGLSWAP *) ); 14 // GCC 4.8 doesnt like WGLSWAP 15 //NV_GL_FUN_REN( DWORD, wglSwapMultipleBuffers, dynwglSwapMultipleBuffers, (UINT, CONST WGLSWAP *) ); 15 16 16 17 // Global -
trunk/nv/stl/algorithm.hh
r374 r376 219 219 { 220 220 detail::fill_impl( first, last, value, 221 integral_constant< bool,sizeof( T ) == 1 && has_trivial_assign<T>::value >() );221 bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() ); 222 222 } 223 223 … … 226 226 { 227 227 return detail::fill_n_impl( first, count, value, 228 integral_constant< bool,sizeof( T ) == 1 && has_trivial_assign<T>::value >() );228 bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() ); 229 229 } 230 230 … … 235 235 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 236 236 detail::fill_impl( first, last, value_type(), 237 integral_constant< bool,sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );237 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() ); 238 238 } 239 239 … … 244 244 typedef typename iterator_traits< ForwardIterator >::value_type value_type; 245 245 return detail::fill_n_impl( first, count, value_type(), 246 integral_constant< bool,sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );246 bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() ); 247 247 } 248 248 -
trunk/nv/stl/array.hh
r375 r376 84 84 }; 85 85 86 // TODO: using array =87 86 template< typename T, size_t N > 88 class array : public array_base< T, 89 fixed_container_storage< static_storage< T, N > > 90 > 91 { 92 93 }; 87 using array = array_base < T, fixed_container_storage < static_storage< T, N > > >; 88 94 89 95 90 #if 0 -
trunk/nv/stl/handle.hh
r368 r376 93 93 { 94 94 value_type index = h.index(); 95 typedef handle_operator<HANDLE> hop;96 95 NV_ASSERT( m_entries[index].next_free == USED, "Unused handle freed!" ); 97 NV_ASSERT( m_entries[index].counter == h op::get_counter( h ), "Handle corruption!" );96 NV_ASSERT( m_entries[index].counter == handle_operator<HANDLE>::get_counter( h ), "Handle corruption!" ); 98 97 m_entries[index].next_free = NONE; 99 98 if ( m_last_free == NONE ) -
trunk/nv/stl/limits.hh
r374 r376 47 47 static const signed long sl_max = 2147483647; 48 48 static const signed long sl_bit = sizeof( signed long ) * 8; 49 static const u int64ull_min = 0;50 static const u int64ull_max = 18446744073709551615;51 static const u int64 ull_bit = sizeof( uint64) * 8;52 static const si nt64sll_min = -9223372036854775808;53 static const si nt64sll_max = 9223372036854775807;54 static const si nt64 sll_bit = sizeof( sint64) * 8;49 static const unsigned long long ull_min = 0; 50 static const unsigned long long ull_max = 18446744073709551615; 51 static const unsigned long long ull_bit = sizeof( unsigned long long ) * 8; 52 static const signed long long sll_min = -9223372036854775808; 53 static const signed long long sll_max = 9223372036854775807; 54 static const signed long long sll_bit = sizeof( signed long long ) * 8; 55 55 56 56 static const int f_dig = 6; … … 311 311 312 312 template<> 313 struct numeric_limits < u int64> : detail::numeric_limits_int_base314 { 315 static NV_CONSTEXPR u int64min() NV_NOEXCEPT { return limits::ull_min; }316 static NV_CONSTEXPR u int64 max() NV_NOEXCEPT{ return limits::ull_max; }317 static NV_CONSTEXPR u int64 lowest() NV_NOEXCEPT{ return limits::ull_min; }318 static NV_CONSTEXPR u int64 epsilon() NV_NOEXCEPT{ return 0; }319 static NV_CONSTEXPR u int64 round_error() NV_NOEXCEPT{ return 0; }313 struct numeric_limits < unsigned long long > : detail::numeric_limits_int_base 314 { 315 static NV_CONSTEXPR unsigned long long min() NV_NOEXCEPT { return limits::ull_min; } 316 static NV_CONSTEXPR unsigned long long max() NV_NOEXCEPT{ return limits::ull_max; } 317 static NV_CONSTEXPR unsigned long long lowest() NV_NOEXCEPT{ return limits::ull_min; } 318 static NV_CONSTEXPR unsigned long long epsilon() NV_NOEXCEPT{ return 0; } 319 static NV_CONSTEXPR unsigned long long round_error() NV_NOEXCEPT{ return 0; } 320 320 321 321 static const bool is_signed = false; … … 325 325 326 326 template<> 327 struct numeric_limits < si nt64> : detail::numeric_limits_int_base328 { 329 static NV_CONSTEXPR si nt64 min() NV_NOEXCEPT{ return limits::sll_min; }330 static NV_CONSTEXPR si nt64 max() NV_NOEXCEPT{ return limits::sll_max; }331 static NV_CONSTEXPR si nt64 lowest() NV_NOEXCEPT{ return limits::sll_min; }332 static NV_CONSTEXPR si nt64 epsilon() NV_NOEXCEPT{ return 0; }333 static NV_CONSTEXPR si nt64 round_error() NV_NOEXCEPT{ return 0; }327 struct numeric_limits < signed long long > : detail::numeric_limits_int_base 328 { 329 static NV_CONSTEXPR signed long long min() NV_NOEXCEPT{ return limits::sll_min; } 330 static NV_CONSTEXPR signed long long max() NV_NOEXCEPT{ return limits::sll_max; } 331 static NV_CONSTEXPR signed long long lowest() NV_NOEXCEPT{ return limits::sll_min; } 332 static NV_CONSTEXPR signed long long epsilon() NV_NOEXCEPT{ return 0; } 333 static NV_CONSTEXPR signed long long round_error() NV_NOEXCEPT{ return 0; } 334 334 335 335 static const bool is_signed = true; -
trunk/nv/stl/memory.hh
r375 r376 20 20 #include <nv/stl/utility.hh> 21 21 #include <nv/stl/iterator.hh> 22 23 #include <type_traits> 22 #include <nv/stl/capi.hh> 24 23 25 24 namespace nv 26 25 { 26 27 27 template< typename T > 28 28 class storage_view … … 111 111 fixed_dynamic_storage() 112 112 { 113 m_data = malloc( N * sizeof( value_type ) );113 m_data = nvmalloc( N * sizeof( value_type ) ); 114 114 } 115 115 ~fixed_dynamic_storage() 116 116 { 117 free( m_data );117 nvfree( m_data ); 118 118 } 119 119 static NV_CONSTEXPR size_t capacity() { return N; } -
trunk/nv/stl/string.hh
r375 r376 283 283 } 284 284 285 #if NV_COMPILER == NV_GNUC286 template< typename T >287 struct string_length : public detail::string_length_impl <288 typename remove_cv < typename remove_reference< T >::type >::type >289 {290 };291 #else292 285 template< typename T > 293 286 using string_length = detail::string_length_impl < 294 287 typename remove_cv < typename remove_reference< T >::type >::type >; 295 #endif296 288 297 289 // These could be done much better 298 290 template <typename T> 299 291 struct is_cstring 300 : public integral_constant < bool,292 : bool_constant < 301 293 is_same< char *, typename decay< T >::type >::value || 302 294 is_same< const char *, typename decay< T >::type >::value > … … 306 298 template <typename T> 307 299 struct is_stdstring 308 : public integral_constant < bool, 309 is_same< std::string, typename remove_cvr< T >::type >::value 310 > 311 { 312 }; 313 314 template < typename T > struct is_string : public integral_constant < bool, is_stdstring<T>::value || is_cstring<T>::value > {}; 300 : bool_constant < is_same< std::string, typename remove_cvr< T >::type >::value > 301 { 302 }; 303 304 template < typename T > struct is_string : bool_constant < is_stdstring<T>::value || is_cstring<T>::value > {}; 315 305 316 306 template<typename T> -
trunk/nv/stl/type_traits.hh
r374 r376 12 12 // TODO: remove typeinfo? 13 13 14 14 15 #ifndef NV_STL_TYPE_TRAITS_HH 15 16 #define NV_STL_TYPE_TRAITS_HH … … 17 18 #include <nv/core/common.hh> 18 19 19 #include <type_traits>20 20 namespace nv 21 21 { … … 244 244 template<> struct is_integral_impl< signed long > : true_type {}; 245 245 template<> struct is_integral_impl< unsigned long > : true_type {}; 246 template<> struct is_integral_impl< si nt64 > : true_type{};247 template<> struct is_integral_impl< u int64 > : true_type{};246 template<> struct is_integral_impl< signed long long > : true_type{}; 247 template<> struct is_integral_impl< unsigned long long > : true_type{}; 248 248 249 249 template< typename T > struct is_floating_point_impl : false_type {}; … … 264 264 template<> struct signed_type < unsigned int > { typedef signed int type; }; 265 265 template<> struct signed_type < unsigned long > { typedef signed long type; }; 266 template<> struct signed_type < u int64 > { typedef sint64type; };266 template<> struct signed_type < unsigned long long > { typedef signed long long type; }; 267 267 268 268 template < typename T > … … 277 277 template<> struct unsigned_type < signed int > { typedef unsigned int type; }; 278 278 template<> struct unsigned_type < signed long > { typedef unsigned long type; }; 279 template<> struct unsigned_type < si nt64 > { typedef uint64type; };279 template<> struct unsigned_type < signed long long > { typedef unsigned long long type; }; 280 280 281 281 template < typename T, bool IS_ENUM = is_enum< T >::value > … … 340 340 template <> struct is_signed<signed long> : true_type {}; 341 341 template <> struct is_signed<const signed long> : true_type {}; 342 template <> struct is_signed<si nt64> : true_type{};343 template <> struct is_signed<const si nt64> : true_type{};342 template <> struct is_signed<signed long long> : true_type{}; 343 template <> struct is_signed<const signed long long> : true_type{}; 344 344 345 345 template <typename T> struct is_unsigned : false_type {}; … … 353 353 template <> struct is_unsigned<unsigned long> : true_type{}; 354 354 template <> struct is_unsigned<const unsigned long> : true_type{}; 355 template <> struct is_unsigned<u int64> : true_type{};356 template <> struct is_unsigned<const u int64> : true_type{};355 template <> struct is_unsigned<unsigned long long> : true_type{}; 356 template <> struct is_unsigned<const unsigned long long> : true_type{}; 357 357 358 358 template <> struct is_signed<char> : integral_constant<bool, ( char( 0 ) > char( -1 ) ) >{}; … … 618 618 long double dummy1; 619 619 void* dummy2; 620 sint64dummy3;620 long long dummy3; 621 621 detail::aligned_fptr dummy4; 622 622 detail::aligned_memptr dummy5; -
trunk/src/core/logger.cc
r368 r376 8 8 #include "nv/core/time.hh" 9 9 #include <cstdio> 10 #if NV_ PLATFORM == NV_WINDOWS10 #if NV_COMPILER == NV_MSVC 11 11 #define WIN32_LEAN_AND_MEAN 12 12 #include <Windows.h> … … 51 51 #define NV_LOG_LEVEL_NAME_PAD(level) (log_level_names_pad[ (level) / 10 ]) 52 52 53 #if NV_ PLATFORM == NV_WINDOWS53 #if NV_COMPILER == NV_MSVC 54 54 static unsigned short log_color[] = 55 55 { … … 145 145 size_t ssize = timestamp( stamp ); 146 146 147 #if NV_ PLATFORM == NV_WINDOWS147 #if NV_COMPILER == NV_MSVC 148 148 if ( m_color ) SetConsoleTextAttribute( m_handle, FOREGROUND_INTENSITY ); 149 149 WriteConsole( m_handle, stamp, ssize, nullptr, nullptr ); … … 170 170 else 171 171 fwrite( "] ", 2, 1, stdout ); 172 fwrite( stamp.data(), stamp.size(), 1, stdout );172 fwrite( message.data(), message.size(), 1, stdout ); 173 173 fwrite( "\n", 1, 1, stdout ); 174 174 #endif … … 233 233 : m_color( coloring ) 234 234 { 235 #if NV_ PLATFORM == NV_WINDOWS235 #if NV_COMPILER == NV_MSVC 236 236 m_handle = GetStdHandle( STD_OUTPUT_HANDLE ); 237 237 #else … … 240 240 } 241 241 242 size_t nv::log_sink::timestamp( char* buffer ) const242 nv::size_t nv::log_sink::timestamp( char* buffer ) const 243 243 { 244 244 uint32 ms = get_system_ms(); … … 248 248 unsigned int m = (unsigned int)(secs / 60) % 60; 249 249 unsigned int s = secs % 60; 250 #if NV_ PLATFORM == NV_WINDOWS250 #if NV_COMPILER == NV_MSVC 251 251 sprintf_s( buffer, 16, "%02d:%02d:%02d.%02d", h, m, s, mm ); 252 252 #else -
trunk/src/core/profiler.cc
r371 r376 12 12 using namespace nv; 13 13 14 #if defNV_MSVC14 #if NV_COMPILER == NV_MSVC 15 15 #define snprintf sprintf_s 16 16 #endif -
trunk/src/core/time.cc
r319 r376 7 7 #include "nv/core/logging.hh" 8 8 9 #include <ctime> 10 9 11 #if NV_COMPILER == NV_MSVC 10 12 #define WIN32_LEAN_AND_MEAN … … 13 15 #pragma intrinsic(__rdtsc) 14 16 #else 15 #include <unistd.h> 17 #if NV_COMPILER == NV_GNUC && NV_PLATFORM == NV_WINDOWS 18 // mingw doesn't have usleep nor nanosleep... 19 #include <windows.h> 20 #endif 21 // #include <unistd.h> 22 // #include <time.h> 23 // #include <sys/time.h> 24 // #include <sys/types.h> 25 #include <stdio.h> 26 #include <time.h> 16 27 #include <sys/time.h> 17 28 #endif 18 29 19 #include <ctime> 30 20 31 21 32 struct timer_impl … … 58 69 Sleep( ms ); 59 70 #else 60 usleep( ms * 1000 ); 71 #if NV_COMPILER == NV_GNUC && NV_PLATFORM == NV_WINDOWS 72 Sleep( ms ); 73 #else 74 struct timespec ts; 75 ts.tv_sec = 0; 76 ts.tv_nsec = ms * 1000000; 77 nanosleep(&ts, NULL); 78 // usleep( ms * 1000 ); 79 #endif 61 80 #endif 62 81 } -
trunk/src/formats/assimp_loader.cc
r367 r376 479 479 } 480 480 481 size_t nv::assimp_loader::get_nodes_data_count() const481 nv::size_t nv::assimp_loader::get_nodes_data_count() const 482 482 { 483 483 if ( m_scene == nullptr ) return 0; -
trunk/src/formats/md2_loader.cc
r374 r376 167 167 168 168 source.seek( md2->header.offset_skins, origin::SET ); 169 source.read( md2->skins, sizeof( md2_skin_t), static_cast<size_t>( md2->header.num_skins ) );169 source.read( md2->skins, sizeof( md2_skin_t ), static_cast<nv::size_t>( md2->header.num_skins ) ); 170 170 171 171 source.seek( md2->header.offset_st, origin::SET ); 172 source.read( md2->texcoords, sizeof( md2_texcoord_t), static_cast<size_t>( md2->header.num_st ) );172 source.read( md2->texcoords, sizeof( md2_texcoord_t ), static_cast<nv::size_t>( md2->header.num_st ) ); 173 173 174 174 source.seek( md2->header.offset_tris, origin::SET ); 175 source.read( md2->triangles, sizeof( md2_triangle_t), static_cast<size_t>( md2->header.num_tris ) );175 source.read( md2->triangles, sizeof( md2_triangle_t ), static_cast<nv::size_t>( md2->header.num_tris ) ); 176 176 177 177 source.seek( md2->header.offset_glcmds, origin::SET); 178 source.read( md2->glcmds, sizeof( int), static_cast<size_t>( md2->header.num_glcmds ) );178 source.read( md2->glcmds, sizeof( int ), static_cast<nv::size_t>( md2->header.num_glcmds ) ); 179 179 180 180 md2->frames = new md2_frame_t [ md2->header.num_frames ]; -
trunk/src/formats/md3_loader.cc
r374 r376 161 161 162 162 source.seek( pos + surface->header.ofs_shaders, origin::SET ); 163 source.read( surface->shaders, sizeof( md3_shader_t ), static_cast< size_t>( surface->header.num_shaders ) );163 source.read( surface->shaders, sizeof( md3_shader_t ), static_cast<nv::size_t>( surface->header.num_shaders ) ); 164 164 165 165 source.seek( pos + surface->header.ofs_triangles, origin::SET ); 166 source.read( surface->triangles, sizeof( md3_triangle_t ), static_cast< size_t>( surface->header.num_triangles ) );166 source.read( surface->triangles, sizeof( md3_triangle_t ), static_cast<nv::size_t>( surface->header.num_triangles ) ); 167 167 168 168 source.seek( pos + surface->header.ofs_st, origin::SET ); 169 source.read( surface->st, sizeof( md3_texcoord_t ), static_cast< size_t>( surface->header.num_verts ) );169 source.read( surface->st, sizeof( md3_texcoord_t ), static_cast<nv::size_t>( surface->header.num_verts ) ); 170 170 171 171 source.seek( pos + surface->header.ofs_xyznormal, origin::SET ); 172 source.read( surface->vertices, sizeof( md3_vertex_t ), static_cast< size_t>( surface->header.num_verts * surface->header.num_frames ) );173 174 if ( source.tell() != static_cast< size_t>( pos + surface->header.ofs_end ) ) return false;172 source.read( surface->vertices, sizeof( md3_vertex_t ), static_cast<nv::size_t>( surface->header.num_verts * surface->header.num_frames ) ); 173 174 if ( source.tell() != static_cast<nv::size_t>( pos + surface->header.ofs_end ) ) return false; 175 175 176 176 return true; … … 198 198 md3->tags = new md3_tag_t [ md3->header.num_tags * md3->header.num_frames ]; 199 199 md3->surfaces = new md3_surface_t[ md3->header.num_surfaces ]; 200 std::memset( md3->surfaces, 0, static_cast< size_t >( md3->header.num_surfaces ) * sizeof(md3_surface_t) );200 std::memset( md3->surfaces, 0, static_cast< nv::size_t >( md3->header.num_surfaces ) * sizeof( md3_surface_t ) ); 201 201 202 202 source.seek( md3->header.ofs_frames, origin::SET ); 203 source.read( md3->frames, sizeof( md3_frame_t ), static_cast< size_t>( md3->header.num_frames ) );203 source.read( md3->frames, sizeof( md3_frame_t ), static_cast<nv::size_t>( md3->header.num_frames ) ); 204 204 205 205 if ( md3->header.num_tags > 0 ) 206 206 { 207 207 source.seek( md3->header.ofs_tags, origin::SET ); 208 source.read( md3->tags, sizeof( md3_tag_t ), static_cast< size_t>( md3->header.num_tags * md3->header.num_frames ) );208 source.read( md3->tags, sizeof( md3_tag_t ), static_cast<nv::size_t>( md3->header.num_tags * md3->header.num_frames ) ); 209 209 } 210 210 … … 321 321 }; 322 322 323 mesh_data* nv::md3_loader::release_mesh_data( size_t index )323 mesh_data* nv::md3_loader::release_mesh_data( nv::size_t index ) 324 324 { 325 325 mesh_data* data = new mesh_data; … … 417 417 } 418 418 419 mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( size_t )419 mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t ) 420 420 { 421 421 md3_t* md3 = (md3_t*)m_md3; … … 464 464 } 465 465 466 size_t md3_loader::get_max_frames() const466 nv::size_t md3_loader::get_max_frames() const 467 467 { 468 468 return static_cast< size_t >( ((md3_t*)m_md3)->header.num_frames ); -
trunk/src/formats/md5_loader.cc
r374 r376 24 24 static void remove_quotes( std::string& str ) 25 25 { 26 size_t n;26 nv::size_t n; 27 27 while ( ( n = str.find('\"') ) != std::string::npos ) str.erase(n,1); 28 28 } -
trunk/src/formats/obj_loader.cc
r374 r376 53 53 std::string next_name; 54 54 55 size_t size;55 nv::size_t size; 56 56 bool eof; 57 57 58 58 obj_reader(); 59 59 bool read_stream( std::istream& stream ); 60 virtual size_t add_face( uint32* vi, uint32* ti, uint32* ni,size_t count ) = 0;61 virtual size_t raw_size() const = 0;60 virtual nv::size_t add_face( uint32* vi, uint32* ti, uint32* ni, nv::size_t count ) = 0; 61 virtual nv::size_t raw_size() const = 0; 62 62 virtual void reset() = 0; 63 63 virtual const uint8* raw_pointer() const = 0; … … 172 172 { 173 173 mesh_data_reader( bool normals ) : m_normals( normals ) {} 174 virtual size_t add_face( uint32* vi, uint32* ti, uint32* ni,size_t count )174 virtual nv::size_t add_face( uint32* vi, uint32* ti, uint32* ni, nv::size_t count ) 175 175 { 176 176 if ( count < 3 ) return 0; // TODO : report error? … … 178 178 // TODO : support if normals not present; 179 179 vec3 nullvec; 180 size_t result = 0;180 nv::size_t result = 0; 181 181 // Simple triangulation - obj's shouldn't have more than quads anyway 182 182 183 183 if ( m_normals ) 184 184 { 185 for ( size_t i = 2; i < count; ++i )185 for ( nv::size_t i = 2; i < count; ++i ) 186 186 { 187 187 result++; … … 193 193 else 194 194 { 195 for ( size_t i = 2; i < count; ++i )195 for ( nv::size_t i = 2; i < count; ++i ) 196 196 { 197 197 result++; … … 206 206 std::vector< VTX > m_data; 207 207 virtual void reset() { m_data.clear(); } 208 virtual size_t raw_size() const { return m_data.size() * sizeof( VTX ); }208 virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); } 209 209 virtual const uint8* raw_pointer() const { return (const uint8*)m_data.data(); } 210 210 }; … … 233 233 // std::vector< vec3 >& tg = m_mesh->get_tangents(); 234 234 235 size_t count= m_data.size();236 size_t tcount = count / 3;235 nv::size_t count = m_data.size(); 236 nv::size_t tcount = count / 3; 237 237 238 238 std::vector< vec3 > tan1( count ); 239 239 std::vector< vec3 > tan2( count ); 240 240 241 for ( size_t a = 0; a < tcount; ++a )242 { 243 size_t i1 = a * 3;244 size_t i2 = a * 3 + 1;245 size_t i3 = a * 3 + 2;241 for ( nv::size_t a = 0; a < tcount; ++a ) 242 { 243 nv::size_t i1 = a * 3; 244 nv::size_t i2 = a * 3 + 1; 245 nv::size_t i3 = a * 3 + 2; 246 246 obj_vertex_vtnt& vtx1 = m_data[ i1 ]; 247 247 obj_vertex_vtnt& vtx2 = m_data[ i2 ]; … … 278 278 } 279 279 280 for ( size_t a = 0; a < count; ++a )280 for ( nv::size_t a = 0; a < count; ++a ) 281 281 { 282 282 const vec3& n = m_data[a].normal; -
trunk/src/gfx/image.cc
r374 r376 7 7 using namespace nv; 8 8 9 image::image( glm::ivec2 size, size_t depth )9 image::image( glm::ivec2 size, nv::size_t depth ) 10 10 : m_size( size ), m_depth( depth ), m_data( nullptr ) 11 11 { … … 20 20 21 21 22 image::image( glm::ivec2 size, size_t depth, const uint8 * data, bool reversed )22 image::image( glm::ivec2 size, nv::size_t depth, const uint8 * data, bool reversed ) 23 23 : m_size( size ), m_depth( depth ), m_data( nullptr ) 24 24 { -
trunk/src/gfx/keyframed_mesh.cc
r367 r376 36 36 } 37 37 38 size_t keyframed_mesh::get_max_frames() const38 nv::size_t keyframed_mesh::get_max_frames() const 39 39 { 40 40 return m_frame_count; -
trunk/src/gfx/texture_atlas.cc
r367 r376 11 11 using namespace nv; 12 12 13 texture_atlas::texture_atlas( glm::ivec2 size, size_t depth,size_t border /*= 1*/ )13 texture_atlas::texture_atlas( glm::ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ ) 14 14 : image( size, depth ), m_used( 0 ), m_border( border ) 15 15 { … … 82 82 } 83 83 84 int texture_atlas::fit( size_t index, glm::ivec2 size )84 int texture_atlas::fit( nv::size_t index, glm::ivec2 size ) 85 85 { 86 86 glm::ivec3 node = m_nodes[ index ]; -
trunk/src/gl/gl_context.cc
r365 r376 329 329 } 330 330 331 void gl_context::update( buffer b, const void* data, size_t offset,size_t size )331 void gl_context::update( buffer b, const void* data, nv::size_t offset, nv::size_t size ) 332 332 { 333 333 const gl_buffer_info* info = static_cast< const gl_buffer_info* >( m_device->get_buffer_info( b ) ); … … 748 748 } 749 749 750 void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count )750 void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, nv::size_t count ) 751 751 { 752 752 apply_render_state( rs ); -
trunk/src/gui/gui_gfx_renderer.cc
r367 r376 107 107 { 108 108 public: 109 screen_render_data( context* actx, size_t initial_size )109 screen_render_data( context* actx, nv::size_t initial_size ) 110 110 : buffer( actx, VERTEX_BUFFER, DYNAMIC_DRAW, initial_size ), ctx( actx ), varray(), shader() 111 111 { … … 175 175 } 176 176 177 texture_font* gfx_renderer::get_font( size_t name ) const177 texture_font* gfx_renderer::get_font( nv::size_t name ) const 178 178 { 179 179 if ( name >= m_fonts.size() ) return nullptr; … … 181 181 } 182 182 183 const image_info* gfx_renderer::get_image( size_t name ) const183 const image_info* gfx_renderer::get_image( nv::size_t name ) const 184 184 { 185 185 if ( name >= m_images.size() ) return nullptr; … … 187 187 } 188 188 189 size_t gfx_renderer::load_font( const std::string& filename,size_t size )189 nv::size_t gfx_renderer::load_font( const std::string& filename, nv::size_t size ) 190 190 { 191 191 std::string id_name( filename ); … … 205 205 } 206 206 207 size_t gfx_renderer::load_image( const std::string& filename )207 nv::size_t gfx_renderer::load_image( const std::string& filename ) 208 208 { 209 209 auto i = m_image_names.find( filename ); -
trunk/src/io/c_stream.cc
r374 r376 3 3 // For conditions of distribution and use, see copyright notice in nv.hh 4 4 5 #include "nv/io/c_stream.hh" 5 6 #include <cstdio> 6 7 #include <sys/stat.h> 7 #include "nv/io/c_stream.hh"8 8 9 9 using namespace nv; … … 33 33 } 34 34 35 size_t c_stream::read( void* buffer, size_t size,size_t count )35 nv::size_t c_stream::read( void* buffer, nv::size_t size, nv::size_t count ) 36 36 { 37 37 NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to read!" ); … … 39 39 } 40 40 41 size_t c_stream::write( const void* buffer, size_t size,size_t count )41 nv::size_t c_stream::write( const void* buffer, nv::size_t size, nv::size_t count ) 42 42 { 43 43 NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to write!" ); … … 50 50 } 51 51 52 size_t c_stream::tell()52 nv::size_t c_stream::tell() 53 53 { 54 return m_file != nullptr ? static_cast< size_t >( ::ftell( (FILE*)m_file ) ) : 0;54 return m_file != nullptr ? static_cast< nv::size_t >( ::ftell( (FILE*)m_file ) ) : 0; 55 55 } 56 56 57 size_t c_stream::size()57 nv::size_t c_stream::size() 58 58 { 59 59 if ( m_file == nullptr || m_file_name == nullptr ) -
trunk/src/lua/lua_path.cc
r360 r376 32 32 } 33 33 34 void lua::path::push( size_t value )34 void lua::path::push( nv::size_t value ) 35 35 { 36 36 m_elements[ m_count ].value = value; -
trunk/src/lua/lua_state.cc
r368 r376 166 166 } 167 167 168 size_t lua::table_guard::get_size()168 nv::size_t lua::table_guard::get_size() 169 169 { 170 170 return lua_rawlen( m_state, -1 );
Note: See TracChangeset
for help on using the changeset viewer.