- Timestamp:
- 07/12/16 20:22:23 (9 years ago)
- Location:
- trunk
- Files:
-
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/base/common.hh
r486 r505 224 224 typedef unsigned long long uint64; 225 225 226 typedef signed long long sintmax; 227 typedef unsigned long long uintmax; 228 226 229 typedef unsigned char uchar8; 227 230 typedef unsigned short uchar16; -
trunk/nv/core/io_event.hh
r447 r505 46 46 struct key_event 47 47 { 48 /// Associated window ID 49 uint32 window_id; 50 48 51 /// Input event ASCII code 49 52 uchar8 ascii; … … 70 73 struct mouse_button_event 71 74 { 75 /// Associated window ID 76 uint32 window_id; 77 72 78 /// X position where mouse was clicked. 73 79 uint16 x; … … 84 90 struct mouse_wheel_event 85 91 { 92 /// Associated window ID 93 uint32 window_id; 86 94 /// amount scrolled horizontally positive to the right 87 95 sint32 x; … … 92 100 struct mouse_move_event 93 101 { 102 /// Associated window ID 103 uint32 window_id; 94 104 /// X Position the mouse moved to. 95 105 uint16 x; -
trunk/nv/core/resource.hh
r487 r505 44 44 //virtual void release( resource_id id ) = 0; 45 45 virtual bool exists( resource_id id ) = 0; 46 virtual bool load_resource( const string_view& id ) = 0;46 virtual bool load_resource( const string_view& ) { return false; }; 47 47 48 48 template< typename T > -
trunk/nv/engine/animation.hh
r487 r505 378 378 }; 379 379 380 class animator_bind_manager : public nv::manual_resource_manager< nv::animator_bind_data > 381 { 382 public: 383 animator_bind_manager() {} 384 using nv::manual_resource_manager< nv::animator_bind_data >::add; 385 using nv::manual_resource_manager< nv::animator_bind_data >::exists; 386 protected: 387 }; 380 388 381 389 } -
trunk/nv/engine/image_manager.hh
r504 r505 24 24 NV_RTTI_DECLARE_NAME( image_data, "image_data" ) 25 25 26 class image_manager : public manual_resource_manager< image_data >26 class image_manager : public file_resource_manager< image_data > 27 27 { 28 28 public: 29 29 image_manager() {} 30 void add_base_path( const string_view& path );31 30 protected: 32 31 virtual bool load_resource( const string_view& id ); 33 vector< string128 > m_paths;34 32 }; 35 33 -
trunk/nv/engine/material_manager.hh
r486 r505 48 48 }; 49 49 50 class gpu_material_manager : public manual_resource_manager< gpu_material>50 class gpu_material_manager : public dependant_resource_manager< gpu_material, material_manager > 51 51 { 52 52 public: 53 53 gpu_material_manager( context* context, material_manager* matmgr, image_manager* imgmgr ); 54 54 protected: 55 virtual bool load_resource( const string_view& id);55 resource< gpu_material > create_resource( resource< material > m ); 56 56 virtual void release( gpu_material* m ); 57 57 private: 58 58 texture m_default; 59 59 context* m_context; 60 material_manager* m_material_manager;61 60 image_manager* m_image_manager; 62 61 }; -
trunk/nv/engine/mesh_manager.hh
r484 r505 37 37 }; 38 38 39 struct mesh_data 40 { 41 vector< data_node_info > infos; 42 vector< resource< data_channel_set > > meshes; 43 hash_store< shash64, uint32 > names; 44 hash_store< shash64, uint32 > node_names; 45 data_node_list* node_data; 46 }; 47 39 48 NV_RTTI_DECLARE_NAME( data_channel_set, "data_channel_set" ) 40 49 NV_RTTI_DECLARE_NAME( gpu_mesh, "gpu_mesh" ) 50 NV_RTTI_DECLARE_NAME( mesh_data, "mesh_data" ) 41 51 42 52 using mesh_manager = manual_resource_manager< data_channel_set >; 43 53 44 class gpu_mesh_manager : public nv::manual_resource_manager< gpu_mesh>54 class gpu_mesh_manager : public dependant_resource_manager< gpu_mesh, mesh_manager > 45 55 { 46 56 public: 47 57 gpu_mesh_manager( context* context, mesh_manager* mesh_manager ) 48 : m_context( context ) 49 , m_mesh_manager( mesh_manager ) {} 50 virtual bool load_resource( const string_view& id ); 51 resource< gpu_mesh > load_resource( resource< data_channel_set > mesh ); 58 : dependant_resource_manager( mesh_manager ) 59 , m_context( context ) {} 52 60 protected: 61 resource< gpu_mesh > create_resource( resource< data_channel_set > mesh ); 53 62 virtual void release( gpu_mesh* m ); 54 63 private: 55 64 context* m_context; 56 mesh_manager* m_mesh_manager; 65 }; 66 67 class mesh_data_manager : public file_resource_manager< mesh_data > 68 { 69 public: 70 mesh_data_manager( mesh_manager* meshes ) 71 : m_mesh_manager( meshes ) , m_strings( new string_table ) {} 72 string_view resolve( shash64 h ) { return ( *m_strings )[h]; } 73 resource< data_channel_set > get_path( const string_view& path, 74 resource< mesh_data > default = resource< mesh_data >(), 75 data_node_info* info = nullptr ); 76 ~mesh_data_manager() { delete m_strings; } 77 protected: 78 virtual bool load_resource( const string_view& id ); 79 80 mesh_manager* m_mesh_manager; 81 string_table* m_strings; 57 82 }; 58 83 -
trunk/nv/engine/program_manager.hh
r477 r505 20 20 { 21 21 22 class program_manager : public lua_resource_manager< program, false >22 class program_manager : public file_resource_manager< program, false, lua_resource_manager_base > 23 23 { 24 24 public: … … 30 30 string_buffer load_source( lua::table_guard& table, const string_view& append ); 31 31 virtual void release( program p ); 32 virtual nv::const_string file_to_string( const string_view& path ); 32 33 private: 33 34 context* m_context; -
trunk/nv/engine/resource_system.hh
r487 r505 16 16 #include <nv/common.hh> 17 17 #include <nv/interface/context.hh> 18 #include <nv/stl/file_system.hh> 18 19 #include <nv/core/resource.hh> 19 20 #include <nv/lua/lua_state.hh> 20 21 #include <nv/stl/hash_store.hh> 21 22 #include <nv/stl/vector.hh> 23 #include <nv/stl/string.hh> 22 24 23 25 namespace nv … … 151 153 152 154 153 template < typename T, bool Heap = true >154 class manual_resource_manager : public custom_resource_manager< T, Heap >155 template < typename T, bool Heap = true, typename Base = resource_handler > 156 class manual_resource_manager : public custom_resource_manager< T, Heap, Base > 155 157 { 156 158 public: 157 159 manual_resource_manager() {} 158 using custom_resource_manager< T, Heap >::add; 159 protected: 160 virtual bool load_resource( const nv::string_view& ) { return false; } 161 162 }; 160 using custom_resource_manager< T, Heap, Base >::add; 161 }; 162 163 template < typename T, typename SourceManager, bool Heap = true > 164 class dependant_resource_manager : public manual_resource_manager< T, Heap > 165 { 166 public: 167 typedef SourceManager source_manager_type; 168 typedef typename SourceManager::resource_type source_type; 169 public: 170 explicit dependant_resource_manager( source_manager_type* source ) : m_source( source ) {} 171 virtual resource< T > load_resource( source_type u ) 172 { 173 resource< T > result = get( u.id().value() ); 174 if ( result ) return result; 175 return create_resource( u ); 176 } 177 protected: 178 virtual resource< T > create_resource( source_type u ) = 0; 179 virtual bool load_resource( const string_view& id ) 180 { 181 source_type u = m_source->get( id ); 182 return u && create_resource( u ); 183 } 184 protected: 185 source_manager_type* m_source; 186 }; 187 188 template < typename T, bool Heap = true, typename Base = resource_handler > 189 class file_resource_manager : public manual_resource_manager< T, Heap, Base > 190 { 191 public: 192 explicit file_resource_manager() {} 193 void add_base_path( const string_view& path ) 194 { 195 m_paths.emplace_back( path ); 196 } 197 protected: 198 stream* open_stream( file_system& fs, const string_view& filename ) 199 { 200 if ( fs.exists( filename ) ) return fs.open( filename ); 201 if ( m_paths.size() > 0 ) 202 { 203 for ( const auto& path : m_paths ) 204 { 205 string128 fpath( path ); 206 fpath.append( filename ); 207 if ( fs.exists( fpath ) ) 208 return fs.open( fpath ); 209 } 210 } 211 return nullptr; 212 } 213 214 vector< string128 > m_paths; 215 }; 216 163 217 } 164 218 -
trunk/nv/gl/gl_window.hh
r440 r505 39 39 40 40 virtual void swap_buffers(); 41 virtual void make_current(); 42 virtual uint32 window_id(); 41 43 virtual ~gl_window(); 42 44 private: … … 47 49 void* m_handle; 48 50 void* m_hwnd; 51 void* m_dc; 49 52 gl_context* m_context; 50 53 -
trunk/nv/interface/context.hh
r503 r505 151 151 m_device = a_device; 152 152 } 153 154 153 virtual vertex_array create_vertex_array( const vertex_array_desc& desc ) = 0; 155 154 virtual framebuffer create_framebuffer( uint32 temp_samples = 1 ) = 0; -
trunk/nv/interface/window.hh
r440 r505 36 36 virtual bool poll_event( io_event& event ) = 0; 37 37 virtual void swap_buffers() = 0; 38 virtual void make_current() = 0; 38 39 virtual device* get_device() = 0; 40 virtual uint32 window_id() = 0; 39 41 virtual ~window() {} 40 42 }; -
trunk/nv/lua/lua_state.hh
r503 r505 364 364 virtual ~table_guard(); 365 365 size_t get_size(); 366 366 367 bool has_field( string_view element ); 368 367 369 shash64 get_string_hash_64( string_view element, uint64 defval = 0 ); 368 // remove this one369 shash64 get_string( string_view element, string_table& table, uint64 defval = 0 );370 370 shash64 get_string( string_view element, string_table* table, uint64 defval = 0 ); 371 371 const_string get_string( string_view element, string_view defval = string_view() ); 372 372 string128 get_string128( string_view element, string_view defval = string_view() ); 373 373 374 char get_char( string_view element, char defval = ' ' ); 374 375 int get_integer( string_view element, int defval = 0 ); … … 377 378 float get_float( string_view element, float defval = 0.0 ); 378 379 bool get_boolean( string_view element, bool defval = false ); 380 381 shash64 get_string_hash_64( int i, uint64 defval = 0 ); 382 shash64 get_string( int i, string_table* table, uint64 defval = 0 ); 383 const_string get_string( int i, string_view defval = string_view() ); 384 string128 get_string128( int i, string_view defval = string_view() ); 385 386 char get_char( int i, char defval = ' ' ); 387 int get_integer( int i, int defval = 0 ); 388 unsigned get_unsigned( int i, unsigned defval = 0 ); 389 double get_double( int i, double defval = 0.0 ); 390 float get_float( int i, float defval = 0.0 ); 391 bool get_boolean( int i, bool defval = false ); 392 379 393 bool is_table( string_view element ); 380 394 bool is_number( string_view element ); 381 395 bool is_boolean( string_view element ); 382 396 bool is_string( string_view element ); 397 bool is_table( int i ); 398 bool is_number( int i ); 399 bool is_boolean( int i ); 400 bool is_string( int i ); 401 383 402 template < typename T > 384 403 bool read( const string_view& element, T& t ) -
trunk/nv/sdl/sdl_window.hh
r440 r505 29 29 virtual void set_title( const string_view& title ); 30 30 virtual void swap_buffers(); 31 virtual void make_current(); 32 31 33 32 34 virtual context* get_context() { return m_context; } … … 38 40 virtual bool is_event_pending() { return m_input->is_event_pending(); } 39 41 virtual bool poll_event( io_event& event ) { return m_input->poll_event( event ); } 40 42 void* get_handle() { return m_handle; } 43 virtual uint32 window_id(); 41 44 virtual ~window(); 42 45 private: -
trunk/nv/sdl/sdl_window_manager.hh
r406 r505 31 31 virtual uint32 get_ticks(); 32 32 virtual ~window_manager(); 33 private: 34 void* primal_window; 33 35 }; 34 36 } -
trunk/nv/stl/math/common.hh
r471 r505 109 109 template <> struct is_bool_vec < tvec4< bool > > : true_type {}; 110 110 111 template < typename T > constexpr bool is_vec_v = is_vec<T>::value; 112 template < typename T > constexpr bool is_mat_v = is_mat<T>::value; 113 template < typename T > constexpr bool is_quat_v = is_quat<T>::value; 114 template < typename T > constexpr bool is_fp_v = is_fp<T>::value; 115 template < typename T > constexpr bool is_fp_vec_v = is_fp_vec<T>::value; 116 template < typename T > constexpr bool is_fp_mat_v = is_fp_mat<T>::value; 117 template < typename T > constexpr bool is_fp_quat_v = is_fp_quat<T>::value; 118 template < typename T > constexpr bool is_bool_vec_v = is_bool_vec<T>::value; 119 111 120 namespace detail 112 121 { … … 227 236 typedef math::tmat4< float > mat4; 228 237 238 typedef math::tquat< float > quat; 239 229 240 template < typename T > 230 241 struct make_unsigned< math::tvec2< T > > … … 265 276 } 266 277 278 NV_RTTI_DECLARE( nv::vec2 ) 279 NV_RTTI_DECLARE( nv::vec3 ) 280 NV_RTTI_DECLARE( nv::vec4 ) 281 NV_RTTI_DECLARE( nv::ivec2 ) 282 NV_RTTI_DECLARE( nv::ivec3 ) 283 NV_RTTI_DECLARE( nv::ivec4 ) 284 NV_RTTI_DECLARE( nv::mat2 ) 285 NV_RTTI_DECLARE( nv::mat3 ) 286 NV_RTTI_DECLARE( nv::mat4 ) 287 NV_RTTI_DECLARE( nv::quat ) 288 267 289 #endif // NV_STL_MATH_COMMON_HH -
trunk/nv/stl/math/quaternion.hh
r487 r505 112 112 113 113 }; 114 115 typedef tquat< f32 > quat;116 114 117 115 namespace detail … … 589 587 } 590 588 591 typedef math::quat quat;592 593 589 } 594 590 -
trunk/nv/stl/rtti_types.hh
r397 r505 15 15 16 16 #include <nv/common.hh> 17 #include <nv/stl/math.hh>18 17 19 18 NV_RTTI_DECLARE( void ) … … 30 29 NV_RTTI_DECLARE_NAME( nv::f32, "f32" ) 31 30 NV_RTTI_DECLARE_NAME( nv::f64, "f64" ) 32 NV_RTTI_DECLARE( nv::vec2 )33 NV_RTTI_DECLARE( nv::vec3 )34 NV_RTTI_DECLARE( nv::vec4 )35 NV_RTTI_DECLARE( nv::ivec2 )36 NV_RTTI_DECLARE( nv::ivec3 )37 NV_RTTI_DECLARE( nv::ivec4 )38 NV_RTTI_DECLARE( nv::mat2 )39 NV_RTTI_DECLARE( nv::mat3 )40 NV_RTTI_DECLARE( nv::mat4 )41 NV_RTTI_DECLARE( nv::quat )42 31 43 32 #endif // NV_STL_RTTI_TYPES_HH -
trunk/nv/stl/string/short_string.hh
r485 r505 220 220 using string256 = short_string< 255 >; 221 221 222 223 222 } 224 223 224 NV_RTTI_DECLARE( nv::string32 ) 225 NV_RTTI_DECLARE( nv::string64 ) 226 NV_RTTI_DECLARE( nv::string128 ) 227 NV_RTTI_DECLARE( nv::string256 ) 228 225 229 #endif // NV_STL_STRING_SHORT_STRING_HH -
trunk/nv/stl/type_traits/common.hh
r454 r505 29 29 }; 30 30 31 template < typename T > 32 constexpr T integral_constant_v = integral_constant<T>::value; 33 31 34 // TODO: Propagate 32 35 template< bool B > … … 36 39 typedef bool_constant<false> false_type; 37 40 41 template < typename T > 42 constexpr T bool_constant_v = bool_constant<T>::value; 43 38 44 template< bool Test, typename T = void> 39 45 struct enable_if {}; … … 68 74 template < typename T > 69 75 struct is_same < T, T > : true_type{}; 76 77 template < typename T1, typename T2 > 78 constexpr bool is_same_v = is_same<T1, T2>::value; 70 79 71 80 // TODO: these seem to simple compared to MSVC/GCC - so we'll leave them in … … 73 82 template < typename T > struct is_const : false_type {}; 74 83 template < typename T > struct is_const < T const > : true_type{}; 84 template < typename T > constexpr bool is_const_v = is_const<T>::value; 75 85 template < typename T > struct is_volatile : false_type {}; 76 86 template < typename T > struct is_volatile < T volatile > : true_type{}; 87 template < typename T > constexpr bool is_volatile_v = is_volatile<T>::value; 77 88 // TODO END 78 89 79 90 template < typename T > struct is_lvalue_reference : false_type {}; 80 91 template < typename T > struct is_lvalue_reference < T& > : true_type{}; 92 template < typename T > constexpr bool is_lvalue_reference_v = is_lvalue_reference<T>::value; 81 93 template < typename T > struct is_rvalue_reference : false_type {}; 82 94 template < typename T > struct is_rvalue_reference < T&& > : true_type{}; 95 template < typename T > constexpr bool is_rvalue_reference_v = is_rvalue_reference<T>::value; 83 96 84 97 template < typename T > … … 87 100 is_rvalue_reference<T>::value 88 101 > {}; 102 template < typename T > constexpr bool is_reference_v = is_reference<T>::value; 89 103 90 104 // add const volatile and reference mutators -
trunk/nv/stl/type_traits/primary.hh
r402 r505 45 45 } 46 46 47 template< typename T > struct is_void : is_same < void, remove_cv_t<T> > {}; 48 template< typename T > struct is_nullptr : is_same < nullptr_t, remove_cv_t<T> > {}; 49 template< typename T > struct is_integral : detail::is_integral_impl < remove_cv_t<T> > {}; 50 template< typename T > struct is_floating_point : detail::is_floating_point_impl < remove_cv_t<T> > {}; 47 template < typename T > struct is_void : is_same < void, remove_cv_t<T> > {}; 48 template < typename T > struct is_nullptr : is_same < nullptr_t, remove_cv_t<T> > {}; 49 template < typename T > struct is_integral : detail::is_integral_impl < remove_cv_t<T> > {}; 50 template < typename T > struct is_floating_point : detail::is_floating_point_impl < remove_cv_t<T> > {}; 51 52 template < typename T > constexpr bool is_void_v = is_void<T>::value; 53 template < typename T > constexpr bool is_nullptr_v = is_nullptr<T>::value; 54 template < typename T > constexpr bool is_integral_v = is_integral<T>::value; 55 template < typename T > constexpr bool is_floating_point_v = is_floating_point<T>::value; 56 51 57 52 58 template < typename T > struct is_array : false_type {}; … … 57 63 template < typename T > struct is_union : bool_constant < __is_union( T ) > {}; 58 64 template < typename T > struct is_class : bool_constant < __is_class( T ) > {}; 65 66 template < typename T > constexpr bool is_array_v = is_array<T>::value; 67 template < typename T > constexpr bool is_enum_v = is_enum<T>::value; 68 template < typename T > constexpr bool is_union_v = is_union<T>::value; 69 template < typename T > constexpr bool is_class_v = is_class<T>::value; 59 70 60 71 // is_function_pointer / is_member_function pointer - extension … … 115 126 template< typename T > struct is_function < T&& > : false_type{}; 116 127 128 template < typename T > constexpr bool is_function_pointer_v = is_function_pointer<T>::value; 129 template < typename T > constexpr bool is_member_function_pointer_v = is_member_function_pointer<T>::value; 130 template < typename T > constexpr bool is_member_pointer_v = is_member_pointer<T>::value; 131 template < typename T > constexpr bool is_function_v = is_function<T>::value; 132 117 133 } 118 134 -
trunk/nv/stl/type_traits/properties.hh
r402 r505 53 53 struct is_compound : bool_constant < !is_fundamental< T >::value > {}; 54 54 55 template < typename T > constexpr bool is_fundamental_v = is_fundamental<T>::value; 56 template < typename T > constexpr bool is_arithmetic_v = is_arithmetic<T>::value; 57 template < typename T > constexpr bool is_scalar_v = is_scalar<T>::value; 58 template < typename T > constexpr bool is_object_v = is_object<T>::value; 59 template < typename T > constexpr bool is_compound_v = is_compound<T>::value; 60 55 61 // TODO : confirm conformance 56 62 #if NV_COMPILER == NV_MSVC … … 68 74 template < typename T > struct is_abstract : bool_constant < __is_abstract( T ) > {}; 69 75 76 template < typename T > constexpr bool is_trivially_copyable_v = is_trivially_copyable<T>::value; 77 template < typename T > constexpr bool is_trivial_v = is_trivial<T>::value; 78 template < typename T > constexpr bool is_pod_v = is_pod<T>::value; 79 template < typename T > constexpr bool is_literal_type_v = is_literal_type<T>::value; 80 template < typename T > constexpr bool is_empty_v = is_empty<T>::value; 81 template < typename T > constexpr bool is_polymorphic_v = is_polymorphic<T>::value; 82 template < typename T > constexpr bool is_abstract_v = is_abstract<T>::value; 83 70 84 template < typename T > struct is_signed : false_type {}; 71 85 template <> struct is_signed<char> : bool_constant< ( char( 0 ) > char( -1 ) ) > {}; … … 93 107 template <> struct is_unsigned<unsigned long long> : true_type{}; 94 108 template <> struct is_unsigned<const unsigned long long> : true_type{}; 109 110 template < typename T > constexpr bool is_signed_v = is_signed<T>::value; 111 template < typename T > constexpr bool is_unsigned_v = is_unsigned<T>::value; 95 112 96 113 #if NV_COMPILER == NV_MSVC … … 207 224 struct is_assignable : detail::is_assignable_impl< To, From >::type { }; 208 225 226 template < typename To, typename From > constexpr bool is_assignable_v = is_assignable<To, From>::value; 227 228 209 229 namespace detail 210 230 { … … 230 250 struct is_move_assignable : detail::is_move_assignable_impl < T > {}; 231 251 252 template < typename T > 253 constexpr bool is_copy_assignable_v = is_copy_assignable<T>::value; 254 255 template < typename T > 256 constexpr bool is_move_assignable_v = is_move_assignable<T>::value; 257 232 258 // TODO : implement if needed 233 259 // template < typename T > … … 249 275 250 276 template < typename T > struct has_virtual_destructor : bool_constant < __has_virtual_destructor( T ) > {}; 277 template < typename T > constexpr bool has_virtual_destructor_v = has_virtual_destructor<T>::value; 251 278 252 279 template< typename T > 253 280 struct alignment_of : integral_constant < size_t, alignof( typename remove_reference< T >::type ) > {}; 281 282 template < typename T > constexpr size_t alignment_of_v = alignment_of<T>::value; 254 283 255 284 template < typename T > … … 259 288 template < typename T, size_t N > 260 289 struct rank<T[N]> : integral_constant < size_t, rank<T>::value + 1 > {}; 290 291 template < typename T > constexpr size_t rank_v = rank<T>::value; 261 292 262 293 template < typename T, unsigned N = 0> … … 271 302 struct extent< T[I], N > : integral_constant < size_t, extent<T, N - 1>::value > {}; 272 303 304 template < typename T > constexpr size_t extent_v = extent<T>::value; 305 273 306 template < typename Base, typename Derived > 274 307 struct is_base_of : bool_constant < __is_base_of( Base, Derived ) > {}; 308 309 template < typename Base, typename Derived > 310 constexpr bool is_base_of_v = is_base_of<Base,Derived>::value; 275 311 276 312 #if NV_COMPILER == NV_MSVC … … 281 317 struct is_convertible : detail::is_convertible_impl< From, To >::type {}; 282 318 #endif 319 320 template < typename From, typename To > 321 constexpr bool is_convertible_v = is_convertible<From, To>::value; 283 322 284 323 namespace detail … … 298 337 struct is_template_base_of : bool_constant< detail::is_template_base_of_impl< T, Template >::value > {}; 299 338 300 301 339 // TODO: non-standard, remove? 302 340 template < typename T > struct has_trivial_constructor : bool_constant < __has_trivial_constructor( T ) || __is_pod( T ) > {}; … … 305 343 template < typename T > struct has_trivial_destructor : bool_constant < __has_trivial_destructor( T ) || __is_pod( T ) > {}; 306 344 345 template < typename T > constexpr bool has_trivial_constructor_v = has_trivial_constructor<T>::value; 346 template < typename T > constexpr bool has_trivial_copy_v = has_trivial_copy<T>::value; 347 template < typename T > constexpr bool has_trivial_assign_v = has_trivial_assign<T>::value; 348 template < typename T > constexpr bool has_trivial_destructor_v = has_trivial_destructor<T>::value; 349 307 350 } 308 351 -
trunk/nv/stl/utility/common.hh
r469 r505 51 51 } 52 52 53 template < typename T, typename U = T > 54 inline T exchange( T& t, U&& u ) 55 { 56 T v = nv::move( t ); 57 t = nv::forward<U>( u ); 58 return v; 59 } 60 61 template < typename T > 62 constexpr add_const_t<T>& as_const( T& t ) 63 { 64 return t; 65 } 66 53 67 } 54 68 -
trunk/nv/wx/wx_canvas.hh
r410 r505 50 50 { 51 51 public: 52 explicit wx_gl_canvas( wxWindow *parent ); 52 explicit wx_gl_canvas( wxWindow *parent, input* in ); 53 explicit wx_gl_canvas( wxWindow *parent, wx_gl_canvas *sibling, input* in ); 53 54 virtual void on_update() = 0; 54 55 virtual void stop(); 55 56 virtual void start(); 56 57 virtual void on_idle( wxIdleEvent& evt ); 58 virtual void make_current(); 59 uint32 window_id() { return m_window->window_id(); } 57 60 ~wx_gl_canvas(); 58 61 protected: … … 64 67 nv::window* m_window; 65 68 bool m_render; 69 bool m_main; 66 70 wxDECLARE_EVENT_TABLE(); 67 71 }; -
trunk/src/core/io_event.cc
r487 r505 71 71 72 72 db->create_type<key_event>() 73 .field( "ascii", &key_event::ascii ) 74 .field( "code", &key_event::code ) 75 .field( "shift", &key_event::shift ) 76 .field( "control", &key_event::control ) 77 .field( "alt", &key_event::alt ) 78 .field( "pressed", &key_event::pressed ); 73 .field( "window_id",&key_event::window_id ) 74 .field( "ascii", &key_event::ascii ) 75 .field( "code", &key_event::code ) 76 .field( "shift", &key_event::shift ) 77 .field( "control", &key_event::control ) 78 .field( "alt", &key_event::alt ) 79 .field( "pressed", &key_event::pressed ); 79 80 80 81 db->create_type<mouse_button_event>() 81 .field( "x", &mouse_button_event::x ) 82 .field( "y", &mouse_button_event::y ) 83 .field( "button", &mouse_button_event::button ) 84 .field( "pressed", &mouse_button_event::pressed ) 85 .field( "code", &mouse_button_event::code ); 82 .field( "window_id",&mouse_button_event::window_id ) 83 .field( "x", &mouse_button_event::x ) 84 .field( "y", &mouse_button_event::y ) 85 .field( "button", &mouse_button_event::button ) 86 .field( "pressed", &mouse_button_event::pressed ) 87 .field( "code", &mouse_button_event::code ); 86 88 87 89 db->create_type<mouse_move_event>() 88 .field( "x", &mouse_move_event::x ) 89 .field( "y", &mouse_move_event::y ) 90 .field( "rx", &mouse_move_event::rx ) 91 .field( "ry", &mouse_move_event::ry ) 92 .field( "pressed", &mouse_move_event::pressed ) 93 .field( "code", &mouse_move_event::code ); 90 .field( "window_id",&mouse_move_event::window_id ) 91 .field( "x", &mouse_move_event::x ) 92 .field( "y", &mouse_move_event::y ) 93 .field( "rx", &mouse_move_event::rx ) 94 .field( "ry", &mouse_move_event::ry ) 95 .field( "pressed", &mouse_move_event::pressed ) 96 .field( "code", &mouse_move_event::code ); 94 97 95 98 db->create_type<mouse_wheel_event>() 96 .field( "x", &mouse_wheel_event::x ) 97 .field( "y", &mouse_wheel_event::y ); 99 .field( "window_id",&mouse_wheel_event::window_id ) 100 .field( "x", &mouse_wheel_event::x ) 101 .field( "y", &mouse_wheel_event::y ); 98 102 99 103 db->create_type<pad_button_event>() -
trunk/src/core/types.cc
r503 r505 3 3 #include "nv/interface/clear_state.hh" 4 4 #include "nv/interface/render_state.hh" 5 #include "nv/stl/string.hh" 5 6 6 7 using namespace nv; … … 26 27 db->create_type<ivec3>(); 27 28 db->create_type<ivec4>(); 29 db->create_type<quat>(); 30 db->create_type<string32>(); 31 db->create_type<string64>(); 32 db->create_type<string128>(); 33 db->create_type<string256>(); 28 34 29 35 db->create_type<color_mask>() -
trunk/src/engine/image_manager.cc
r504 r505 12 12 using namespace nv; 13 13 14 void nv::image_manager::add_base_path( const string_view& path)14 bool image_manager::load_resource( const string_view& filename ) 15 15 { 16 m_paths.emplace_back( path ); 16 c_file_system fs; 17 if ( stream* file = open_stream( fs, filename ) ) 18 { 19 png_loader loader; 20 image_data* result = loader.load( *file ); 21 delete file; 22 if ( result ) 23 { 24 add( filename, result ); 25 return true; 26 } 27 } 28 return false; 17 29 } 18 30 19 bool image_manager::load_resource( const string_view& filename )20 {21 png_loader loader;22 c_file_system fs;23 image_data* result = nullptr;24 if ( fs.exists( filename ) )25 {26 stream* file = fs.open( filename );27 result = loader.load( *file );28 delete file;29 }30 else if ( m_paths.size() > 0 )31 {32 for ( const auto& path : m_paths )33 {34 string128 fpath = path;35 fpath.append( filename );36 if ( fs.exists( fpath ) )37 {38 stream* file = fs.open( fpath );39 result = loader.load( *file );40 delete file;41 break;42 }43 }44 }45 if ( result )46 add( filename, result );47 return result != nullptr;48 }49 -
trunk/src/engine/material_manager.cc
r501 r505 14 14 15 15 nv::gpu_material_manager::gpu_material_manager( context* context, material_manager* matmgr, image_manager* imgmgr ) 16 : m_context( context ) 17 , m_material_manager( matmgr ) 16 : dependant_resource_manager( matmgr ), m_context( context ) 18 17 , m_image_manager( imgmgr ) 19 18 { … … 23 22 } 24 23 25 bool gpu_material_manager::load_resource( const string_view& id)24 nv::resource< nv::gpu_material > nv::gpu_material_manager::create_resource( resource< material > m ) 26 25 { 27 if ( auto mat = m_material_manager->get( id ).lock() ) 26 resource_id id = m.id(); 27 if ( auto mat = m.lock() ) 28 28 { 29 29 gpu_material* result = new gpu_material; … … 39 39 40 40 // HACK 41 for ( uint32 i = 0; i < 8; ++i ) 42 if ( result->textures[i].is_nil() ) 43 result->textures[i] = m_default; 44 45 add( id, result ); 46 return true; 41 for ( uint32 i = 0; i < 8; ++i ) 42 if ( result->textures[i].is_nil() ) 43 result->textures[i] = m_default; 44 45 return add( id, result ); 47 46 } 48 return false;47 return resource< nv::gpu_material >(); 49 48 } 50 49 -
trunk/src/engine/mesh_manager.cc
r484 r505 6 6 7 7 #include "nv/engine/mesh_manager.hh" 8 #include "nv/formats/nmd_loader.hh" 9 #include "nv/io/c_file_system.hh" 8 10 9 11 using namespace nv; 10 12 11 resource< gpu_mesh > gpu_mesh_manager:: load_resource( resource< data_channel_set > mesh )13 resource< gpu_mesh > gpu_mesh_manager::create_resource( resource< data_channel_set > mesh ) 12 14 { 13 resource< gpu_mesh > result = get( mesh.id().value() );14 if ( result ) return result;15 15 if ( auto lmesh = mesh.lock() ) 16 16 { … … 24 24 } 25 25 26 bool nv::gpu_mesh_manager::load_resource( const string_view& id )27 {28 if ( auto lmesh = m_mesh_manager->get( id ).lock() )29 {30 gpu_mesh* gm = new gpu_mesh;31 gm->va = m_context->create_vertex_array( &*lmesh, STATIC_DRAW );32 gm->count = lmesh->get_channel_size( slot::INDEX );33 gm->shader = lmesh->get_channel( slot::BONEINDEX ) != nullptr ? BONE : NORMAL;34 add( id, gm );35 return true;36 }37 return false;38 }39 40 26 void gpu_mesh_manager::release( gpu_mesh* m ) 41 27 { 42 28 m_context->release( m->va ); 43 29 } 30 31 nv::resource< nv::data_channel_set > nv::mesh_data_manager::get_path( const string_view& path, resource< mesh_data > default /*= resource< mesh_data >()*/, data_node_info* info /*= nullptr */ ) 32 { 33 nv::resource< nv::mesh_data > mr = default; 34 35 nv::string_view sub_mesh_name; 36 nv::string128 base_mesh_name( path ); 37 nv::size_t sub_mesh_pos = path.find( ":" ); 38 nv::size_t dot_pos = path.find( "." ); 39 if ( sub_mesh_pos != nv::string_view::npos ) 40 { 41 sub_mesh_name = path.substr( sub_mesh_pos + 1 ); 42 base_mesh_name.assign( path.substr( 0, sub_mesh_pos ) ); 43 NV_LOG_INFO( "Requested submesh - [", sub_mesh_name, "] in [", base_mesh_name, "]" ); 44 } 45 46 if ( dot_pos != nv::string_view::npos ) 47 { 48 mr = get( base_mesh_name ); 49 } 50 else 51 { 52 sub_mesh_name = base_mesh_name; 53 } 54 55 if ( !mr ) 56 { 57 NV_LOG_ERROR( "MESH FILE NOT FOUND - ", path ); 58 NV_ASSERT( false, "MESH FILE NOT FOUND!" ); 59 return nv::resource< nv::data_channel_set >(); 60 } 61 62 if ( auto mdata = mr.lock() ) 63 { 64 sint32 index = -1; 65 if ( sub_mesh_name.empty() ) 66 { 67 index = 0; 68 } 69 else if ( sub_mesh_name[0] >= '0' && sub_mesh_name[0] <= '9' ) 70 { 71 index = nv::buffer_to_uint32( sub_mesh_name.data(), nullptr ); 72 } 73 else 74 { 75 auto itr = mdata->names.find( sub_mesh_name ); 76 if ( itr != mdata->names.end() ) 77 index = itr->second; 78 } 79 if ( index >= 0 ) 80 { 81 if ( info ) 82 *info = mdata->infos[index]; 83 return mdata->meshes[index]; 84 } 85 86 NV_LOG_ERROR( "Resource path fail! - ", path ); 87 NV_ASSERT( false, "Resource path fail!" ); 88 } 89 else 90 { 91 NV_LOG_ERROR( "Resource lock fail! - ", path ); 92 NV_ASSERT( false, "Resource lock fail!" ); 93 } 94 return nv::resource< nv::data_channel_set >(); 95 } 96 97 bool nv::mesh_data_manager::load_resource( const string_view& id ) 98 { 99 nmd_loader* loader = nullptr; 100 c_file_system fs; 101 stream* mesh_file = open_stream( fs, id ); 102 if ( !mesh_file ) return false; 103 104 loader = new nmd_loader( m_strings ); 105 loader->load( *mesh_file ); 106 delete mesh_file; 107 108 mesh_data* result = new mesh_data; 109 result->node_data = loader->release_data_node_list(); 110 if ( result->node_data ) 111 { 112 data_node_list* nd = result->node_data; 113 for ( uint32 i = 0; i < nd->size(); ++i ) 114 result->node_names[(*nd)[i].name] = i; 115 } 116 for ( uint32 i = 0; i < loader->get_mesh_count(); ++i ) 117 { 118 data_node_info info; 119 data_channel_set* data = loader->release_mesh_data( i, info ); 120 result->infos.push_back( info ); 121 result->names[ info.name ] = i; 122 auto mesh = m_mesh_manager->add( shash64( id.get_hash() + i ), data ); 123 result->meshes.push_back( mesh ); 124 } 125 delete loader; 126 if ( result ) 127 add( id, result ); 128 return result != nullptr; 129 } -
trunk/src/engine/program_manager.cc
r501 r505 45 45 } 46 46 47 nv::const_string nv::program_manager::file_to_string( const string_view& path ) 48 { 49 c_file_system fs; 50 stream* fstream = open_stream( fs, path ); 51 if ( !fstream ) return const_string(); 52 uint32 size = fstream->size(); 53 const_string result( nullptr, size ); 54 fstream->read( const_cast<char*>( result.data() ), size, 1 ); 55 delete fstream; 56 return result; 57 } 58 47 59 nv::string_buffer nv::program_manager::load_source( lua::table_guard& table, const string_view& append ) 48 60 { … … 51 63 if ( table.is_string( "files" ) ) 52 64 { 53 out.append( f s.slurp( table.get_string( "files" ) ) );65 out.append( file_to_string( table.get_string( "files" ) ) ); 54 66 } 55 67 else if ( table.is_table( "files" ) ) … … 61 73 const_string include( inctable.get<const_string,uint32>(i) ); 62 74 if ( i == count ) out.append( "#line 1\n" ); 63 out.append( f s.slurp( include ) );75 out.append( file_to_string( include ) ); 64 76 } 65 77 } … … 67 79 if ( table.is_string( "file" ) ) 68 80 { 69 const_string data = f s.slurp( table.get_string( "file" ) );81 const_string data = file_to_string( table.get_string( "file" ) ); 70 82 out.append( "#line 1\n" + data ); 71 83 } -
trunk/src/gfx/image.cc
r487 r505 98 98 const uint8* data = idata->get_data(); 99 99 size_t depth = idata->get_depth(); 100 size_t cdepth = m_depth > depth ? depth : m_depth; 100 101 uint32 dstride = rsizex * depth; 101 102 … … 106 107 { 107 108 uint32 xy = pos + x * m_depth; 108 for( size_t e = 0; e < depth; ++e )109 for( size_t e = 0; e < cdepth; ++e ) 109 110 { 110 111 m_data[ xy + e ] = data[ y*dstride + x * depth + e ]; -
trunk/src/gl/gl_context.cc
r503 r505 848 848 } 849 849 850 851 850 nv::gl_context::~gl_context() 852 851 { -
trunk/src/gl/gl_device.cc
r501 r505 145 145 { 146 146 unsigned glid = 0; 147 unsigned glenum = buffer_type_to_enum( type );148 147 glGenBuffers( 1, &glid ); 149 148 -
trunk/src/gl/gl_window.cc
r466 r505 9 9 #include "nv/core/logging.hh" 10 10 #include "nv/lib/gl.hh" 11 #include "nv/lib/sdl.hh" 11 12 12 13 using namespace nv; … … 31 32 delete m_context; 32 33 m_context = nullptr; 33 delete m_input;34 34 } 35 35 … … 41 41 42 42 m_handle = handle; 43 m_dc = dc; 43 44 44 45 // TODO: error checking … … 110 111 } 111 112 113 void nv::gl_window::make_current() 114 { 115 #if NV_PLATFORM == NV_WINDOWS 116 HDC hdc = reinterpret_cast<HDC>( m_hwnd ); 117 dynwglMakeCurrent( hdc, reinterpret_cast<HGLRC>( m_context->get_native_handle() ) ); 118 #endif 119 } 120 121 nv::uint32 nv::gl_window::window_id() 122 { 123 return SDL_GetWindowID( static_cast<SDL_Window*>( m_handle ) ); 124 } 125 -
trunk/src/lua/lua_state.cc
r503 r505 201 201 } 202 202 203 shash64 nv::lua::table_guard::get_string( string_view element, string_table&table, uint64 defval /*= 0 */ )203 nv::shash64 nv::lua::table_guard::get_string( string_view element, string_table* table, uint64 defval /*= 0 */ ) 204 204 { 205 205 lua_getfield( m_state, -1, element.data() ); … … 210 210 { 211 211 str = lua_tolstring( m_state, -1, &l ); 212 result = table.insert( string_view( str, l ) ); 213 } 214 lua_pop( m_state, 1 ); 215 return result; 216 } 217 218 nv::shash64 nv::lua::table_guard::get_string( string_view element, string_table* table, uint64 defval /*= 0 */ ) 219 { 220 lua_getfield( m_state, -1, element.data() ); 212 string_view sv( str, l ); 213 result = table ? table->insert( sv ) : shash64( sv ); 214 } 215 lua_pop( m_state, 1 ); 216 return result; 217 } 218 219 shash64 nv::lua::table_guard::get_string_hash_64( int i, uint64 defval /*= 0 */ ) 220 { 221 lua_rawgeti( m_state, -1, i ); 222 size_t l = 0; 223 const char* str = nullptr; 224 uint64 result = defval; 225 if ( lua_type( m_state, -1 ) == LUA_TSTRING ) 226 { 227 str = lua_tolstring( m_state, -1, &l ); 228 result = hash_string< uint64 >( str, l ); 229 //NV_LOG_DEBUG( str ); 230 } 231 lua_pop( m_state, 1 ); 232 return shash64( result ); 233 } 234 235 nv::string128 nv::lua::table_guard::get_string128( int i, string_view defval /*= string_view() */ ) 236 { 237 lua_rawgeti( m_state, -1, i ); 238 size_t l = 0; 239 const char* str = nullptr; 240 if ( lua_type( m_state, -1 ) == LUA_TSTRING ) 241 { 242 str = lua_tolstring( m_state, -1, &l ); 243 } 244 else 245 { 246 l = defval.size(); 247 str = defval.data(); 248 } 249 string128 result( str, l ); 250 lua_pop( m_state, 1 ); 251 return result; 252 } 253 254 const_string nv::lua::table_guard::get_string( int i, string_view defval /*= string_view() */ ) 255 { 256 lua_rawgeti( m_state, -1, i ); 257 size_t l = 0; 258 const char* str = nullptr; 259 if ( lua_type( m_state, -1 ) == LUA_TSTRING ) 260 { 261 str = lua_tolstring( m_state, -1, &l ); 262 } 263 else 264 { 265 l = defval.size(); 266 str = defval.data(); 267 } 268 const_string result( str, l ); 269 lua_pop( m_state, 1 ); 270 return result; 271 } 272 273 shash64 nv::lua::table_guard::get_string( int i, string_table* table, uint64 defval /*= 0 */ ) 274 { 275 lua_rawgeti( m_state, -1, i ); 221 276 size_t l = 0; 222 277 const char* str = nullptr; … … 302 357 } 303 358 359 char nv::lua::table_guard::get_char( int i, char defval /*= ' ' */ ) 360 { 361 lua_rawgeti( m_state, -1, i ); 362 char result = ( lua_type( m_state, -1 ) == LUA_TSTRING && nlua_rawlen( m_state, -1 ) > 0 ) ? lua_tostring( m_state, -1 )[0] : defval; 363 lua_pop( m_state, 1 ); 364 return result; 365 } 366 367 int nv::lua::table_guard::get_integer( int i, int defval /*= 0 */ ) 368 { 369 lua_rawgeti( m_state, -1, i ); 370 lua_Integer result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tointeger( m_state, -1 ) : defval; 371 lua_pop( m_state, 1 ); 372 return static_cast<int>( result ); 373 } 374 375 unsigned nv::lua::table_guard::get_unsigned( int i, unsigned defval /*= 0 */ ) 376 { 377 lua_rawgeti( m_state, -1, i ); 378 unsigned result = lua_type( m_state, -1 ) == LUA_TNUMBER ? nlua_tounsigned( m_state, -1 ) : defval; 379 lua_pop( m_state, 1 ); 380 return result; 381 } 382 383 double nv::lua::table_guard::get_double( int i, double defval /*= 0.0 */ ) 384 { 385 lua_rawgeti( m_state, -1, i ); 386 double result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tonumber( m_state, -1 ) : defval; 387 lua_pop( m_state, 1 ); 388 return result; 389 } 390 391 float nv::lua::table_guard::get_float( int i, float defval /*= 0.0 */ ) 392 { 393 lua_rawgeti( m_state, -1, i ); 394 float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( m_state, -1 ) ) : defval; 395 lua_pop( m_state, 1 ); 396 return result; 397 } 398 399 bool nv::lua::table_guard::get_boolean( int i, bool defval /*= false */ ) 400 { 401 lua_rawgeti( m_state, -1, i ); 402 bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN ? lua_toboolean( m_state, -1 ) != 0 : defval; 403 lua_pop( m_state, 1 ); 404 return result; 405 } 406 304 407 float nv::lua::table_guard::get_float( string_view element, float defval /*= 0.0 */ ) 305 408 { … … 326 429 } 327 430 431 bool nv::lua::table_guard::is_table( int i ) 432 { 433 lua_rawgeti( m_state, -1, i ); 434 bool result = lua_type( m_state, -1 ) == LUA_TTABLE; 435 lua_pop( m_state, 1 ); 436 return result; 437 } 438 439 bool nv::lua::table_guard::is_number( int i ) 440 { 441 lua_rawgeti( m_state, -1, i ); 442 bool result = lua_type( m_state, -1 ) == LUA_TNUMBER; 443 lua_pop( m_state, 1 ); 444 return result; 445 } 446 447 bool nv::lua::table_guard::is_boolean( int i ) 448 { 449 lua_rawgeti( m_state, -1, i ); 450 bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN; 451 lua_pop( m_state, 1 ); 452 return result; 453 } 454 455 bool nv::lua::table_guard::is_string( int i ) 456 { 457 lua_rawgeti( m_state, -1, i ); 458 bool result = lua_type( m_state, -1 ) == LUA_TSTRING; 459 lua_pop( m_state, 1 ); 460 return result; 461 } 462 328 463 bool nv::lua::table_guard::is_number( string_view element ) 329 464 { … … 349 484 return result; 350 485 } 351 352 486 353 487 bool nv::lua::table_guard::read( const string_view& element, const type_entry* entry, void* object ) -
trunk/src/sdl/sdl_input.cc
r406 r505 20 20 static bool sdl_key_event_to_io_event( const SDL_KeyboardEvent& ke, io_event& kevent ) 21 21 { 22 kevent.type = EV_KEY; 23 kevent.key.pressed = ( ke.state != SDL_RELEASED ); 24 kevent.key.ascii = 0; 25 kevent.key.code = KEY_NONE; 22 kevent.type = EV_KEY; 23 kevent.key.window_id = ke.windowID; 24 kevent.key.pressed = ( ke.state != SDL_RELEASED ); 25 kevent.key.ascii = 0; 26 kevent.key.code = KEY_NONE; 26 27 27 28 uint32 ucode = static_cast<uint32>( ke.keysym.sym ); … … 107 108 static bool sdl_mouse_button_to_io_event( const SDL_MouseButtonEvent& mb, io_event& mevent ) 108 109 { 109 mevent.type = EV_MOUSE_BUTTON; 110 mevent.mbutton.button = MOUSE_NONE; 111 mevent.mbutton.pressed = (mb.state != SDL_RELEASED); 112 mevent.mbutton.x = static_cast< uint16 >( mb.x ); 113 mevent.mbutton.y = static_cast< uint16 >( mb.y ); 110 mevent.type = EV_MOUSE_BUTTON; 111 mevent.mbutton.window_id = mb.windowID; 112 mevent.mbutton.button = MOUSE_NONE; 113 mevent.mbutton.pressed = (mb.state != SDL_RELEASED); 114 mevent.mbutton.x = static_cast< uint16 >( mb.x ); 115 mevent.mbutton.y = static_cast< uint16 >( mb.y ); 114 116 115 117 switch ( mb.button ) … … 126 128 static bool sdl_mouse_wheel_to_io_event( const SDL_MouseWheelEvent& mm, io_event& mevent ) 127 129 { 128 mevent.type = EV_MOUSE_WHEEL; 129 mevent.mwheel.x = static_cast< sint32 >( mm.x ); 130 mevent.mwheel.y = static_cast< sint32 >( mm.y ); 130 mevent.type = EV_MOUSE_WHEEL; 131 mevent.mwheel.window_id = mm.windowID; 132 mevent.mwheel.x = static_cast< sint32 >( mm.x ); 133 mevent.mwheel.y = static_cast< sint32 >( mm.y ); 131 134 return true; 132 135 } … … 134 137 static bool sdl_mouse_motion_to_io_event( const SDL_MouseMotionEvent& mm, io_event& mevent ) 135 138 { 136 mevent.type = EV_MOUSE_MOVE; 137 mevent.mmove.pressed = (mm.state != SDL_RELEASED); 138 mevent.mmove.x = static_cast< uint16 >( mm.x ); 139 mevent.mmove.y = static_cast< uint16 >( mm.y ); 140 mevent.mmove.rx = static_cast< sint16 >( mm.xrel ); 141 mevent.mmove.ry = static_cast< sint16 >( mm.yrel ); 139 mevent.type = EV_MOUSE_MOVE; 140 mevent.mmove.window_id = mm.windowID; 141 mevent.mmove.pressed = (mm.state != SDL_RELEASED); 142 mevent.mmove.x = static_cast< uint16 >( mm.x ); 143 mevent.mmove.y = static_cast< uint16 >( mm.y ); 144 mevent.mmove.rx = static_cast< sint16 >( mm.xrel ); 145 mevent.mmove.ry = static_cast< sint16 >( mm.yrel ); 142 146 return true; 143 147 } … … 222 226 case SDL_VIDEOEXPOSE : return false; 223 227 */ 228 case SDL_WINDOWEVENT_ENTER: ioevent.type = EV_SYSTEM; ioevent.system.param1 = 1; ioevent.system.param1 = e.window.windowID; return true; 229 case SDL_WINDOWEVENT_LEAVE: ioevent.type = EV_SYSTEM; ioevent.system.param1 = 0; ioevent.system.param1 = e.window.windowID; return true; 224 230 case SDL_SYSWMEVENT : ioevent.type = EV_SYSTEM; return true; 225 231 case SDL_QUIT : ioevent.type = EV_QUIT; return true; -
trunk/src/sdl/sdl_window.cc
r492 r505 133 133 SDL_GL_SetSwapInterval( enabled ? 1 : 0 ); 134 134 } 135 136 void nv::sdl::window::make_current() 137 { 138 SDL_GLContext native = static_cast<SDL_GLContext>( m_context->get_native_handle() ); 139 SDL_GL_MakeCurrent( static_cast<SDL_Window*>( m_handle ), native ); 140 } 141 142 nv::uint32 nv::sdl::window::window_id() 143 { 144 return SDL_GetWindowID( static_cast<SDL_Window*>( m_handle ) ); 145 } -
trunk/src/sdl/sdl_window_manager.cc
r395 r505 17 17 sdl::window_manager::window_manager() 18 18 { 19 primal_window = nullptr; 19 20 nv::load_sdl_library(); 20 21 … … 29 30 { 30 31 if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO ); 31 return new sdl::window( dev, width, height, fullscreen ); 32 sdl::window* result = new sdl::window( dev, width, height, fullscreen ); 33 primal_window = result->get_handle(); 34 return result; 32 35 } 33 36 … … 35 38 { 36 39 if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO ); 37 return SDL_CreateWindowFrom( sys_w_handle ); 40 if ( primal_window ) 41 { 42 char buffer[128]; 43 sprintf( buffer, "%p", primal_window ); 44 NV_ASSERT( SDL_SetHint( "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT", buffer ) == SDL_TRUE ); 45 } 46 primal_window = SDL_CreateWindowFrom( sys_w_handle ); 47 return primal_window; 38 48 } 39 49 -
trunk/src/wx/wx_canvas.cc
r470 r505 13 13 wxEND_EVENT_TABLE() 14 14 15 nv::wx_gl_canvas::wx_gl_canvas( wxWindow *parent )15 nv::wx_gl_canvas::wx_gl_canvas( wxWindow *parent, input* in ) 16 16 : wxWindow( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 17 17 wxFULL_REPAINT_ON_RESIZE ) … … 19 19 nv::load_gl_no_context(); 20 20 wxClientDC dc( this ); 21 m_render = true; 22 m_wm = new nv::sdl::window_manager; 23 m_device = new nv::gl_device(); 24 if ( !in ) in = new nv::sdl::input; 25 m_window = new nv::gl_window( m_device, m_wm, in, GetHWND(), dc.GetHDC() ); 26 m_context = m_window->get_context(); 27 m_main = true; 28 } 29 30 nv::wx_gl_canvas::wx_gl_canvas( wxWindow *parent, wx_gl_canvas *sibling, input* in ) 31 : wxWindow( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 32 wxFULL_REPAINT_ON_RESIZE ) 33 { 34 wxClientDC dc( this ); 21 35 m_render = true; 22 m_wm = new nv::sdl::window_manager;36 m_wm = sibling->m_wm; 23 37 m_device = new nv::gl_device(); 24 m_window = new nv::gl_window( m_device, m_wm, new nv::sdl::input(), GetHWND(), dc.GetHDC() ); 38 if ( !in ) in = new nv::sdl::input; 39 m_window = new nv::gl_window( m_device, m_wm, in, GetHWND(), dc.GetHDC() ); 25 40 m_context = m_window->get_context(); 41 make_current(); 42 m_main = false; 43 26 44 } 27 45 28 46 nv::wx_gl_canvas::~wx_gl_canvas() 29 47 { 48 make_current(); 30 49 delete m_window; 31 50 delete m_device; … … 34 53 void nv::wx_gl_canvas::on_paint( wxPaintEvent& ) 35 54 { 55 make_current(); 36 56 const wxSize client_size = GetClientSize(); 37 57 m_context->set_viewport( nv::ivec4( nv::ivec2(), client_size.x, client_size.y ) ); … … 53 73 void nv::wx_gl_canvas::on_idle( wxIdleEvent& evt ) 54 74 { 55 nv::sleep( 1 0);75 nv::sleep( 1 ); 56 76 if ( m_render ) 57 77 { 78 make_current(); 58 79 on_update(); 59 80 evt.RequestMore(); // render continuously, not only once on idle 60 81 } 82 } 83 84 void nv::wx_gl_canvas::make_current() 85 { 86 m_window->make_current(); 61 87 } 62 88
Note: See TracChangeset
for help on using the changeset viewer.