Changeset 406
- Timestamp:
- 06/20/15 00:05:17 (10 years ago)
- Location:
- trunk
- Files:
-
- 72 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/base/common.hh
r403 r406 162 162 #endif 163 163 164 #define NV_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ( (nv::size_t)(!(sizeof(x) % sizeof(0[x])))))164 #define NV_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / (static_cast<nv::size_t>(!(sizeof(x) % sizeof(0[x]))))) 165 165 #define NV_SAFE_ARRAY( arr, idx, def ) ( index < NV_COUNT_OF(arr) ? (arr)[idx] : (def) ) 166 166 … … 186 186 namespace nv 187 187 { 188 188 189 template < typename T > 189 190 struct static_assert_fail … … 263 264 } 264 265 266 template< typename T > 267 void void_assign( T*& out, void* in ) 268 { 269 out = reinterpret_cast<T*>( in ); 270 } 271 272 enum log_level 273 { 274 LOG_NONE = 0, 275 LOG_FATAL = 10, 276 LOG_CRITICAL = 20, 277 LOG_ERROR = 30, 278 LOG_WARNING = 40, 279 LOG_NOTICE = 50, 280 LOG_INFO = 60, 281 LOG_DEBUG = 80, 282 LOG_TRACE = 100 283 }; 284 285 using log_handler_t = void( *)( int, const char*, size_t ); 286 287 log_handler_t get_log_handler(); 288 void set_log_handler( log_handler_t ); 289 265 290 } // namespace nv 266 291 -
trunk/nv/core/logging.hh
r402 r406 21 21 namespace nv 22 22 { 23 24 enum log_level25 {26 LOG_NONE = 0,27 LOG_FATAL = 10,28 LOG_CRITICAL = 20,29 LOG_ERROR = 30,30 LOG_WARNING = 40,31 LOG_NOTICE = 50,32 LOG_INFO = 60,33 LOG_DEBUG = 80,34 LOG_TRACE = 10035 };36 23 37 24 class logger_base : public singleton< logger_base > … … 90 77 inline void log_sequence( log_level level, T&& t, Args&&... args ) 91 78 { 92 log_append( t );93 log_sequence( level, nv::forward<Args>( args )... );79 this->log_append( t ); 80 this->log_sequence( level, nv::forward<Args>( args )... ); 94 81 } 95 82 virtual ~logger_base() {} 96 83 protected: 97 char m_message[ 256];84 char m_message[1024]; 98 85 char* m_pos; 99 86 unsigned int m_level; -
trunk/nv/gfx/animation.hh
r401 r406 57 57 if ( count == 0 ) return 0; 58 58 uint32 keyfsize = desc.size / 4; 59 const float* fdata = ((const float*)data) + keyfsize * index;59 const float* fdata = reinterpret_cast<const float*>( data ) + keyfsize * index; 60 60 uint32 mod = 0; 61 61 if ( desc.slots[0].vslot == animation_slot::TIME ) mod = 1; … … 69 69 uint32 keyfsize = desc.size / 4; 70 70 uint32 keyfresult = keyfsize; 71 const float* fdata = (const float*)data;71 const float* fdata = reinterpret_cast<const float*>( data ); 72 72 73 73 uint32 slot = 0; … … 87 87 for ( unsigned i = 1 ; i < count ; i++ ) 88 88 { 89 if ( time < fdata[ i * keyfsize ] ) { index0 = (int)i - 1; break; } 89 if ( time < fdata[ i * keyfsize ] ) 90 { 91 index0 = static_cast<int>(i) - 1; 92 break; 93 } 90 94 } 91 95 NV_ASSERT( index0 >= 0, "animation time fail!"); 92 96 index1 = index0 + 1; 93 float time0 = fdata[ index0 * (int)keyfsize];94 float time1 = fdata[ index1 * (int)keyfsize];97 float time0 = fdata[ index0 * static_cast<int>( keyfsize ) ]; 98 float time1 = fdata[ index1 * static_cast<int>( keyfsize ) ]; 95 99 float delta = time1 - time0; 96 100 factor = glm::clamp( (time - time0) / delta, 0.0f, 1.0f ); … … 103 107 return keyfresult; 104 108 } 105 index0 = glm::clamp<int>( (int) time, 0, (int)count- 2 );109 index0 = glm::clamp<int>( int( time ), 0, int( count ) - 2 ); 106 110 index1 = index0 + 1; 107 111 factor = glm::clamp<float> ( time - index0, 0.0f, 1.0f ); … … 112 116 ret += nv::interpolate_raw( 113 117 desc.slots[slot], factor, 114 fdata + index0 * (int)keyfsize+ desc.slots[slot].offset / 4,115 fdata + index1 * (int)keyfsize+ desc.slots[slot].offset / 4,118 fdata + index0 * static_cast<int>( keyfsize ) + desc.slots[slot].offset / 4, 119 fdata + index1 * static_cast<int>( keyfsize ) + desc.slots[slot].offset / 4, 116 120 result + ret ); 117 121 } … … 225 229 if ( m_data->count == 1 ) 226 230 { 227 result = ((KEY*)m_data->data)[0];231 result = reinterpret_cast<KEY*>(m_data->data)[0]; 228 232 return; 229 233 } 230 234 size_t index = glm::clamp<size_t>( size_t( frame ), 0, m_data->count - 2 ); 231 235 float factor = glm::clamp<float> ( frame - index, 0.0f, 1.0f ); 232 KEY* keys = ((KEY*)m_data->data);236 KEY* keys = reinterpret_cast<KEY*>( m_data->data ); 233 237 interpolate_key( result, keys[index], keys[index+1], factor ); 234 238 } … … 254 258 { 255 259 // TODO: this probably could be optimized 256 const KEY* keys = (const KEY*)(m_data->data);260 const KEY* keys = reinterpret_cast<const KEY*>(m_data->data); 257 261 NV_ASSERT( m_data, "Data is null!" ); 258 262 if ( m_data->count == 0 ) return; … … 263 267 } 264 268 int index = -1; 265 for ( int i = 0 ; i < (int)m_data->count- 1 ; i++ )269 for ( int i = 0 ; i < int( m_data->count ) - 1 ; i++ ) 266 270 { 267 271 if ( time < keys[i + 1].time ) { index = i; break; } … … 375 379 bool empty() const { return m_channel->count == 0; } 376 380 size_t size() const { return m_channel->count; } 377 const transform& get( size_t index ) const { return ((key*)(m_channel->data))[ index ].tform; }378 const transform* data() const { return (const transform*)m_channel->data; }381 const transform& get( size_t index ) const { return reinterpret_cast<key*>(m_channel->data)[ index ].tform; } 382 const transform* data() const { return reinterpret_cast<const transform*>( m_channel->data ); } 379 383 380 384 virtual uint32 raw_size() const -
trunk/nv/gfx/sliced_buffer.hh
r395 r406 112 112 if ( !m_full_update && resized ) 113 113 { 114 m_data.erase( m_data.begin() + (int)offset, m_data.end() );114 m_data.erase( m_data.begin() + int( offset ), m_data.end() ); 115 115 m_min = nv::min<size_t>( m_min, offset ); 116 116 m_full_update = true; … … 124 124 { 125 125 // raw_copy( bv.cbegin(), bv.cend(), m_data.begin() + (int)offset ); 126 raw_copy( bv.data(), bv.data() + bv.size(), m_data.data() + (int)offset);126 raw_copy( bv.data(), bv.data() + bv.size(), m_data.data() + int( offset ) ); 127 127 m_min = nv::min<size_t>( m_min, offset ); 128 128 m_max = nv::max<size_t>( m_max, offset + bv.size() ); … … 157 157 { 158 158 bool result = false; 159 size_t bsize = (size_t)get_max_size();159 size_t bsize = get_max_size(); 160 160 if ( m_data.size() > bsize ) 161 161 { -
trunk/nv/gl/gl_context.hh
r395 r406 49 49 virtual void bind( texture t, texture_slot slot ); 50 50 51 virtual void update( texture t, void* data );51 virtual void update( texture t, const void* data ); 52 52 virtual void update( buffer b, const void* data, size_t offset, size_t size ); 53 53 -
trunk/nv/gl/gl_device.hh
r399 r406 46 46 virtual program create_program( string_view vs_source, string_view fs_source ); 47 47 virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ); 48 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr );48 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr ); 49 49 50 50 virtual void release( buffer b ); -
trunk/nv/gui/gui_ascii_renderer.hh
r395 r406 45 45 } // namespace nv 46 46 47 #endif // NV_ GUI_RENDERER_HH47 #endif // NV_ASCII_RENDERER_HH -
trunk/nv/interface/animation_key.hh
r395 r406 193 193 struct key_descriptor 194 194 { 195 key_descriptor_slot slots[ (uint16)animation_slot::SLOT_MAX_STORE];195 key_descriptor_slot slots[ uint16( animation_slot::SLOT_MAX_STORE ) ]; 196 196 uint32 count; 197 197 uint32 size; -
trunk/nv/interface/context.hh
r399 r406 102 102 virtual void bind( framebuffer f, framebuffer_slot slot = FRAMEBUFFER ) = 0; 103 103 virtual void bind( texture, texture_slot ) = 0; 104 virtual void update( texture, void* ) = 0;104 virtual void update( texture, const void* ) = 0; 105 105 virtual void update( buffer, const void*, size_t /*offset*/, size_t /*size*/ ) = 0; 106 106 … … 267 267 if ( info ) 268 268 { 269 NV_ASSERT( info->count < (uint16)vertex_array_info::MAX_ATTRIBUTES, "MAX_ATTRIBUTES reached!" );269 NV_ASSERT( info->count < uint16( vertex_array_info::MAX_ATTRIBUTES ), "MAX_ATTRIBUTES reached!" ); 270 270 vertex_buffer_attribute& p = info->attr[ info->count ]; 271 271 p.vbuffer = buf; -
trunk/nv/interface/device.hh
r399 r406 159 159 virtual program create_program( string_view vs_source, string_view fs_source ) = 0; 160 160 virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ) = 0; 161 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) = 0;161 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr ) = 0; 162 162 // TODO: remove? 163 virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); }163 virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); } 164 164 virtual image_data* create_image_data( string_view filename ) = 0; // temporary 165 165 virtual image_data* create_image_data( const uint8* data, uint32 size ) = 0; // temporary … … 173 173 virtual texture create_texture( image_data* data, sampler asampler ) 174 174 { 175 return create_texture( data->get_size(), data->get_format(), asampler, (void*)data->get_data() );175 return create_texture( data->get_size(), data->get_format(), asampler, data->get_data() ); 176 176 } 177 177 … … 192 192 { 193 193 // TODO: nicer check 194 NV_ASSERT( (int)count<= base->get_length(), "LENGTH CHECK FAIL" );195 ((uniform<T>*)( base ))->set_value( value, count );194 NV_ASSERT( static_cast<int>( count ) <= base->get_length(), "LENGTH CHECK FAIL" ); 195 static_cast< uniform<T>* >( base )->set_value( value, count ); 196 196 } 197 197 } … … 207 207 void set_opt_uniform_array( program p, const std::string& name, const array_view<T>& value ) 208 208 { 209 set_uniform_array( p, name, (const T*)value.data(), value.size(), false );209 set_uniform_array( p, name, value.data(), value.size(), false ); 210 210 } 211 211 … … 219 219 if ( base->type_check( type_to_enum<T>::type ) ) 220 220 { 221 ((uniform<T>*)( base ))->set_value( value );221 static_cast< uniform<T>* >( base )->set_value( value ); 222 222 } 223 223 } -
trunk/nv/interface/interpolation_raw.hh
r398 r406 29 29 inline uint32 interpolate_raw_quat( float factor, const float* k1, const float* k2, float* result ) 30 30 { 31 *( (quat*)(result)) = interpolate( *((quat*)(k1)), *((quat*)(k2)), factor );31 *( reinterpret_cast<quat*>(result) ) = interpolate( *( reinterpret_cast<const quat*>(k1) ), *( reinterpret_cast<const quat*>(k2) ), factor ); 32 32 return 4; 33 33 } … … 53 53 { 54 54 quat result; 55 memcpy( (float*)(&result), data, sizeof(quat));55 memcpy(reinterpret_cast<float*>(&result), data, sizeof(quat)); 56 56 return result; 57 57 } … … 139 139 inline void transform_key_position( uint8* data, float scale, const mat3& r33 ) 140 140 { 141 vec3& p = *( (vec3*)(data));141 vec3& p = *( reinterpret_cast<vec3*>( data ) ); 142 142 p = r33 * p * scale; 143 143 } 144 144 inline void transform_key_rotation( uint8* data, const mat3& r33, const mat3& ri33 ) 145 145 { 146 quat& r = *( (quat*)(data));146 quat& r = *( reinterpret_cast<quat*>( data ) ); 147 147 r = quat_cast( r33 * mat3_cast( r ) * ri33 ); 148 148 } 149 149 inline void transform_key_scale( void* data, float scale ) 150 150 { 151 vec3& s = *( (vec3*)(data));151 vec3& s = *( reinterpret_cast<vec3*>( data ) ); 152 152 s = s * scale; 153 153 } 154 154 inline void transform_key_transform( uint8* data, float scale, const mat3& r33, const mat3& ri33 ) 155 155 { 156 transform& t = *( (transform*)(data));156 transform& t = *( reinterpret_cast<transform*>( data ) ); 157 157 t = transform( 158 158 r33 * t.get_position() * scale, -
trunk/nv/interface/mesh_data.hh
r399 r406 136 136 if ( ch->desc.slots[i].vslot == s ) 137 137 { 138 return (int)c;138 return int( c ); 139 139 } 140 140 } … … 180 180 if ( ch->desc == compare ) 181 181 { 182 return (VTX*)ch->data;182 return reinterpret_cast<VTX*>( ch->data ); 183 183 } 184 184 } … … 266 266 { 267 267 if ( m_nodes[ i ].name == name ) 268 return (int)i;268 return int( i ); 269 269 } 270 270 return -1; -
trunk/nv/interface/uniform.hh
r399 r406 106 106 typedef uniform<T> uniform_type; 107 107 108 engine_uniform( uniform_base* u ) : m_uniform( (uniform<T>*)u) {}108 engine_uniform( uniform_base* u ) : m_uniform( static_cast<uniform<T>*>( u ) ) {} 109 109 protected: 110 110 uniform<T>* m_uniform; … … 145 145 146 146 engine_link_uniform() {} 147 virtual void set( uniform_base* u ) { set_impl( (uniform<T>*)u); }147 virtual void set( uniform_base* u ) { set_impl( static_cast<uniform<T>*>(u) ); } 148 148 virtual void set_impl( uniform<T>* u ) = 0; 149 149 }; -
trunk/nv/interface/vertex.hh
r395 r406 238 238 struct vertex_descriptor 239 239 { 240 vertex_descriptor_slot slots[ (uint16)slot::SLOT_MAX_STORE];240 vertex_descriptor_slot slots[ uint16( slot::SLOT_MAX_STORE ) ]; 241 241 uint32 count; 242 242 uint32 size; -
trunk/nv/lib/assimp.hh
r398 r406 67 67 inline mat4 assimp_mat4_cast( const aiMatrix4x4& m ) 68 68 { 69 const float* p = (float*)&m;69 const float* p = reinterpret_cast<const float*>( &m ); 70 70 return glm::transpose( make_mat4( p ) ); 71 71 } -
trunk/nv/lib/detail/assimp_types.inc
r247 r406 381 381 #define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "?bg.global",0,0 382 382 383 #define _AI_MATKEY_TEXTURE_BASE "$tex.file"384 #define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"385 #define _AI_MATKEY_TEXOP_BASE "$tex.op"386 #define _AI_MATKEY_MAPPING_BASE "$tex.mapping"387 #define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"388 #define _AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu"389 #define _AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev"390 #define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"391 #define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"392 #define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"383 #define AI_MATKEY_TEXTURE_BASE "$tex.file" 384 #define AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc" 385 #define AI_MATKEY_TEXOP_BASE "$tex.op" 386 #define AI_MATKEY_MAPPING_BASE "$tex.mapping" 387 #define AI_MATKEY_TEXBLEND_BASE "$tex.blend" 388 #define AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu" 389 #define AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev" 390 #define AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis" 391 #define AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo" 392 #define AI_MATKEY_TEXFLAGS_BASE "$tex.flags" 393 393 394 394 struct aiVectorKey -
trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_blit_functions.inc
r311 r406 1 1 /* GL_EXT_FRAMEBUFFER_BLIT */ 2 2 NV_GL_FUN_EXT( void , glBlitFramebuffer , ( GLint , GLint , GLint , GLint , GLint , GLint , GLint , GLint , GLbitfield , GLenum ) ); 3 -
trunk/nv/lib/detail/sdl_keys.inc
r325 r406 532 532 SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) 533 533 }; 534 -
trunk/nv/lib/freetype2.hh
r395 r406 104 104 105 105 #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ 106 (FT_Tag)\107 ( ( (FT_ULong)_x1<< 24 ) | \108 ( (FT_ULong)_x2<< 16 ) | \109 ( (FT_ULong)_x3<< 8 ) | \110 (FT_ULong)_x4)106 static_cast<FT_Tag>( \ 107 ( static_cast<FT_ULong>(_x1) << 24 ) | \ 108 ( static_cast<FT_ULong>(_x2) << 16 ) | \ 109 ( static_cast<FT_ULong>(_x3) << 8 ) | \ 110 static_cast<FT_ULong>(_x4) ) 111 111 112 112 /* ftimage.h */ … … 214 214 #ifndef FT_IMAGE_TAG 215 215 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ 216 value = ( ( (unsigned long)_x1<< 24 ) | \217 ( (unsigned long)_x2<< 16 ) | \218 ( (unsigned long)_x3<< 8 ) | \219 (unsigned long)_x4)216 value = ( ( static_cast<unsigned long>(_x1) << 24 ) | \ 217 ( static_cast<unsigned long>(_x2) << 16 ) | \ 218 ( static_cast<unsigned long>(_x3) << 8 ) | \ 219 static_cast<unsigned long>(_x4) ) 220 220 #endif /* FT_IMAGE_TAG */ 221 221 … … 383 383 #ifndef FT_ENC_TAG 384 384 #define FT_ENC_TAG( value, a, b, c, d ) \ 385 value = ( ( (FT_UInt32)(a) << 24 ) | \386 ( (FT_UInt32)(b) << 16 ) | \387 ( (FT_UInt32)(c) << 8 ) | \388 (FT_UInt32)(d) )385 value = ( ( static_cast<FT_UInt32>(a) << 24 ) | \ 386 ( static_cast<FT_UInt32>(b) << 16 ) | \ 387 ( static_cast<FT_UInt32>(c) << 8 ) | \ 388 static_cast<FT_UInt32>(d) ) 389 389 390 390 #endif /* FT_ENC_TAG */ … … 671 671 #define FT_LOAD_ADVANCE_ONLY 0x100 672 672 #define FT_LOAD_SBITS_ONLY 0x4000 673 #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )673 #define FT_LOAD_TARGET_( x ) ( static_cast<FT_UInt32>( (x) & 15 ) << 16 ) 674 674 #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) 675 675 #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) … … 677 677 #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) 678 678 #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) 679 #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )679 #define FT_LOAD_TARGET_MODE( x ) ( static_cast<FT_Render_Mode>( ( (x) >> 16 ) & 15 ) ) 680 680 681 681 typedef enum FT_Render_Mode_ -
trunk/nv/lib/lua.hh
r395 r406 367 367 extern int LUA_VERSION_NUM; 368 368 #define lua_upvalueindex(i) (LUA_UPVALUEINDEX-(i)) 369 #define lua_tounsigned(L,idx) (lua_Unsigned)lua_tointeger(L,idx)370 #define lua_pushunsigned(L,u) lua_pushinteger(L, (lua_Integer)u)369 #define lua_tounsigned(L,idx) static_cast<lua_Unsigned>( lua_tointeger(L,idx) ) 370 #define lua_pushunsigned(L,u) lua_pushinteger(L,static_cast<lua_Integer>( u ) ) 371 371 #define lua_objlen lua_rawlen 372 372 #endif -
trunk/nv/lua/lua_area.hh
r395 r406 24 24 extern const char* AREA_METATABLE; 25 25 inline bool is_area( lua_State* L, int index ) { return is_userdata( L, index, AREA_METATABLE ); } 26 inline rectangle to_area( lua_State* L, int index ) { return * (rectangle*)check_userdata( L, index, AREA_METATABLE); }27 inline rectangle* to_parea( lua_State* L, int index ) { return (rectangle*)check_userdata( L, index, AREA_METATABLE); }26 inline rectangle to_area( lua_State* L, int index ) { return *reinterpret_cast<rectangle*>( check_userdata( L, index, AREA_METATABLE ) ); } 27 inline rectangle* to_parea( lua_State* L, int index ) { return reinterpret_cast<rectangle*>( check_userdata( L, index, AREA_METATABLE ) ); } 28 28 inline void push_area( lua_State* L, const rectangle& v ) { push_userdata( L, v, AREA_METATABLE ); } 29 29 -
trunk/nv/lua/lua_dispatch.hh
r395 r406 134 134 int object_method_wrapper( lua_State* L ) 135 135 { 136 C* c = (C*)to_ref_object( L, 1);136 C* c = reinterpret_cast<C*>( to_ref_object( L, 1 ) ); 137 137 return dispatch( L, 2, c, f ); 138 138 } … … 141 141 int fixed_method_wrapper( lua_State* L ) 142 142 { 143 C* c = (C*)to_pointer( L, nv::lua::detail::upvalue_index(1) );143 C* c = reinterpret_cast<C*>( to_pointer( L, nv::lua::detail::upvalue_index(1) ) ); 144 144 return dispatch( L, 1, c, f ); 145 145 } -
trunk/nv/lua/lua_function.hh
r395 r406 81 81 } // namespace nv 82 82 83 #endif // NV_LUA_ HH83 #endif // NV_LUA_FUNCTION_HH -
trunk/nv/lua/lua_glm.hh
r397 r406 37 37 T to_vec( lua_State* L, int index ) 38 38 { 39 return * (T*)check_userdata( L, index, detail::glm_metatable_name<T>() );39 return *reinterpret_cast<T*>( check_userdata( L, index, detail::glm_metatable_name<T>() ) ); 40 40 } 41 41 … … 43 43 T to_vec( lua_State* L, int index, const T& def ) 44 44 { 45 return ( is_vec<T>( L, index ) ? * (T*)to_pointer( L, index) : def );45 return ( is_vec<T>( L, index ) ? *reinterpret_cast<T*>( to_pointer( L, index ) ) : def ); 46 46 } 47 47 … … 49 49 T* to_pvec( lua_State* L, int index ) 50 50 { 51 return (T*)check_userdata( L, index, detail::glm_metatable_name<T>() );51 return reinterpret_cast<T*>( check_userdata( L, index, detail::glm_metatable_name<T>() ) ); 52 52 } 53 53 -
trunk/nv/lua/lua_values.hh
r399 r406 242 242 inline void pop_value( lua_State *L, T& p ) 243 243 { 244 p = (T)pass_traits< type_degrade_t<T> >::to( L, -1);244 p = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1 ) ); 245 245 detail::pop_and_discard(L, 1); 246 246 } … … 248 248 inline T pop_return_value( lua_State *L ) 249 249 { 250 T ret; 251 ret = (T)pass_traits< type_degrade_t<T> >::to( L, -1 ); 250 T ret = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1 ) ); 252 251 detail::pop_and_discard(L, 1); 253 252 return ret; … … 262 261 inline void pop_value( lua_State *L, T& p, const T& def ) 263 262 { 264 p = (T)pass_traits< type_degrade_t<T> >::to( L, -1, def);263 p = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1, def ) ); 265 264 detail::pop_and_discard(L, 1); 266 265 } … … 268 267 inline T pop_return_value( lua_State *L, const T& def ) 269 268 { 270 T ret; 271 ret = (T)pass_traits< type_degrade_t<T> >::to( L, -1, def ); 269 T ret = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1, def ) ); 272 270 detail::pop_and_discard(L, 1); 273 271 return ret; -
trunk/nv/stl/container/contiguous_storage.hh
r401 r406 91 91 { 92 92 if ( copy_needed ) 93 m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type) );93 m_data = static_cast<uint8*>( nvrealloc( m_data, new_size * sizeof( value_type ) ) ); 94 94 else 95 95 { 96 96 nvfree( m_data ); 97 m_data = ( new_size > 0 ? (uint8*)nvmalloc( new_size * sizeof( value_type) ) : nullptr );97 m_data = ( new_size > 0 ? static_cast<uint8*>( nvmalloc( new_size * sizeof( value_type ) ) ) : nullptr ); 98 98 } 99 99 return true; // TODO : alloc check? -
trunk/nv/stl/container/contiguous_storage_policy.hh
r401 r406 66 66 } 67 67 static constexpr size_type max_size() { return size_type( 0x80000000 ); } 68 constexpr size_t capacity() { return m_size; }68 constexpr size_t capacity() const { return m_size; } 69 69 constexpr size_t size() const { return m_size; } 70 70 constexpr bool empty() const { return m_size == 0; } … … 135 135 } 136 136 static constexpr size_type max_size() { return size_type( 0x80000000 ); } 137 constexpr size_t capacity() { return m_capacity; }137 constexpr size_t capacity() const { return m_capacity; } 138 138 constexpr size_t size() const { return m_size; } 139 139 constexpr bool empty() const { return m_size == 0; } -
trunk/nv/stl/flags.hh
r395 r406 48 48 private: 49 49 reference() : m_flags( nullptr ), m_index( index_type(0) ) {} 50 50 reference( const reference& ) = default; 51 51 reference( flags<SIZE,T>* a_flags, index_type a_index ) 52 52 : m_flags( a_flags ), m_index( a_index ) … … 109 109 { 110 110 if ( raw_index_type(m_index) >= SIZE ) { m_flags = nullptr; m_index = index_type(0); return; } 111 m_index = index_type( (raw_index_type)m_index + 1);111 m_index = index_type( raw_index_type( m_index + 1 ) ); 112 112 } while ( !m_flags->test( m_index ) ); 113 113 } -
trunk/nv/stl/handle.hh
r395 r406 99 99 if ( m_last_free == NONE ) 100 100 { 101 m_first_free = m_last_free = (index_type)index;101 m_first_free = m_last_free = static_cast<index_type>( index ); 102 102 return; 103 103 } 104 m_entries[ (value_type)m_last_free].next_free = (index_type)index;105 m_last_free = (index_type)index;104 m_entries[static_cast<value_type>( m_last_free ) ].next_free = static_cast<index_type>( index ); 105 m_last_free = static_cast<index_type>( index ); 106 106 } 107 107 … … 128 128 if ( m_first_free != NONE ) 129 129 { 130 value_type result = (value_type)m_first_free;130 value_type result = static_cast<value_type>( m_first_free ); 131 131 m_first_free = m_entries[result].next_free; 132 132 m_entries[result].next_free = USED; … … 165 165 T* insert( handle h ) 166 166 { 167 resize_indexes_to( (index_type) h.index() );168 m_indexes[ h.index() ] = (index_type) m_data.size();167 resize_indexes_to( index_type( h.index() ) ); 168 m_indexes[ h.index() ] = index_type( m_data.size() ); 169 169 m_handles.push_back( h ); 170 170 m_data.emplace_back(); … … 182 182 if ( h.is_nil() || h.index() >= m_indexes.size() ) return nullptr; 183 183 index_type i = m_indexes[ h.index() ]; 184 return i >= 0 ? &(m_data[ (unsigned)i]) : nullptr;184 return i >= 0 ? &(m_data[ unsigned( i ) ]) : nullptr; 185 185 } 186 186 … … 189 189 if ( h.is_nil() || h.index() >= m_indexes.size() ) return nullptr; 190 190 index_type i = m_indexes[h.index()]; 191 return i >= 0 ? &( m_data[ (unsigned)i] ) : nullptr;191 return i >= 0 ? &( m_data[ unsigned( i )] ) : nullptr; 192 192 } 193 193 … … 196 196 if ( h.is_nil() || h.index() >= m_indexes.size() || m_indexes[h.index()] == -1 ) 197 197 return; 198 handle swap_handle = m_handles.back();199 sint32dead_eindex = m_indexes[ h.index() ];200 if ( dead_eindex != (sint32)m_data.size()-1)198 handle swap_handle = m_handles.back(); 199 index_type dead_eindex = m_indexes[ h.index() ]; 200 if ( dead_eindex != static_cast<index_type>( m_data.size()-1 ) ) 201 201 { 202 m_data[ (unsigned)dead_eindex] = m_data.back();203 m_handles[ (unsigned)dead_eindex] = swap_handle;204 m_indexes[ swap_handle.index() ] = dead_eindex;202 m_data[ unsigned( dead_eindex ) ] = m_data.back(); 203 m_handles[unsigned( dead_eindex ) ] = swap_handle; 204 m_indexes[ swap_handle.index() ] = dead_eindex; 205 205 } 206 206 m_data.pop_back(); … … 216 216 } 217 217 218 handle get_handle( index_type i ) const { return m_handles[ (unsigned)i]; }218 handle get_handle( index_type i ) const { return m_handles[unsigned(i)]; } 219 219 220 220 const value_type& operator[] ( index_type i ) const { return m_data[i]; } … … 233 233 void resize_indexes_to( index_type i ) 234 234 { 235 index_type size = (index_type)m_indexes.size();235 index_type size = index_type( m_indexes.size() ); 236 236 if ( i >= size ) 237 237 { 238 238 if ( size == 0 ) size = 1; 239 239 while ( i >= size ) size = size * 2; 240 m_indexes.resize( (size_t)size, -1 );240 m_indexes.resize( static_cast<size_t>( size ), -1 ); 241 241 } 242 242 } … … 297 297 298 298 handle get_handle( index_type i ) const { return m_data.get_handle(i); } 299 const value_type& operator[] ( index_type i ) const { return m_data[ (unsigned)i]; }300 value_type& operator[] ( index_type i ) { return m_data[ (unsigned)i]; }299 const value_type& operator[] ( index_type i ) const { return m_data[unsigned(i)]; } 300 value_type& operator[] ( index_type i ) { return m_data[unsigned(i)]; } 301 301 size_t size() const { return m_data.size(); } 302 302 -
trunk/nv/stl/range.hh
r397 r406 105 105 bits_iterator_base( T value, T current ) : forward_iterator_base<T>( current ), m_full( value ) 106 106 { 107 if( !( (base_type)value & (base_type)current) )107 if( !( static_cast<base_type>( value ) & static_cast<base_type>( current ) ) ) 108 108 next(); 109 109 } … … 125 125 { 126 126 if ( base_class::m_value == invalid || m_full <= base_class::m_value ) { base_class::m_value = invalid; m_full = invalid; break; } 127 base_class::m_value = T( (base_type)base_class::m_value<< 1);128 } while ( !( (base_type)m_full & (base_type)base_class::m_value) );127 base_class::m_value = T( static_cast<base_type>( base_class::m_value ) << 1); 128 } while ( !( static_cast<base_type>( m_full ) & static_cast<base_type>( base_class::m_value ) ) ); 129 129 } 130 130 -
trunk/src/curses/curses_terminal.cc
r395 r406 20 20 noecho(); 21 21 22 nodelay ( (WINDOW*)m_screen, true );23 intrflush( (WINDOW*)m_screen, false );24 keypad ( (WINDOW*)m_screen, true );22 nodelay ( static_cast<WINDOW*>( m_screen ), true ); 23 intrflush( static_cast<WINDOW*>( m_screen ), false ); 24 keypad ( static_cast<WINDOW*>( m_screen ), true ); 25 25 26 26 start_color(); … … 89 89 90 90 // Get value from curses 91 int result = wgetch( (WINDOW*)m_screen);91 int result = wgetch( static_cast<WINDOW*>( m_screen ) ); 92 92 93 93 // If value is err, return none event -
trunk/src/engine/particle_engine.cc
r395 r406 194 194 static bool nv_particle_affector_linear_force_init( lua::table_guard* table, particle_affector_data* data ) 195 195 { 196 nvpe_linear_force_data* datap = ((nvpe_linear_force_data*)data->paramters);196 nvpe_linear_force_data* datap = reinterpret_cast<nvpe_linear_force_data*>( data->paramters ); 197 197 datap->force_vector = table->get<vec3>("force_vector", vec3() ); 198 198 datap->average = table->get<bool>("average", false ); … … 202 202 static void nv_particle_affector_linear_force( const particle_affector_data* data, particle* p, float factor, uint32 count ) 203 203 { 204 nvpe_linear_force_data* datap = ((nvpe_linear_force_data*)data->paramters);204 const nvpe_linear_force_data* datap = reinterpret_cast<const nvpe_linear_force_data*>( data->paramters ); 205 205 if ( datap->average ) 206 206 { … … 226 226 static bool nv_particle_affector_deflector_plane_init( lua::table_guard* table, particle_affector_data* data ) 227 227 { 228 nvpe_deflector_plane_data* datap = ((nvpe_deflector_plane_data*)data->paramters);228 nvpe_deflector_plane_data* datap = reinterpret_cast<nvpe_deflector_plane_data*>( data->paramters ); 229 229 datap->plane_point = table->get<vec3>("plane_point", vec3() ); 230 230 datap->plane_normal = table->get<vec3>("plane_normal", vec3(0.0f,1.0f,0.0f) ); … … 237 237 static void nv_particle_affector_deflector_plane( const particle_affector_data* data, particle* p, float factor, uint32 count ) 238 238 { 239 nvpe_deflector_plane_data* datap = ((nvpe_deflector_plane_data*)data->paramters);239 const nvpe_deflector_plane_data* datap = reinterpret_cast<const nvpe_deflector_plane_data*>( data->paramters ); 240 240 for ( uint32 i = 0; i < count; ++i ) 241 241 { … … 262 262 static bool nv_particle_affector_color_fader_init( lua::table_guard* table, particle_affector_data* data ) 263 263 { 264 nvpe_color_fader_data* datap = ((nvpe_color_fader_data*)data->paramters);264 nvpe_color_fader_data* datap = reinterpret_cast<nvpe_color_fader_data*>( data->paramters ); 265 265 datap->adjustment = table->get<vec4>("adjustment", vec4() ); 266 266 return true; … … 269 269 static void nv_particle_affector_color_fader( const particle_affector_data* data, particle* p, float factor, uint32 count ) 270 270 { 271 nvpe_color_fader_data* datap = ((nvpe_color_fader_data*)data->paramters);271 const nvpe_color_fader_data* datap = reinterpret_cast<const nvpe_color_fader_data*>( data->paramters ); 272 272 vec4 adjustment = datap->adjustment * factor; 273 273 for ( uint32 i = 0; i < count; ++i ) … … 284 284 static bool nv_particle_affector_scaler_init( lua::table_guard* table, particle_affector_data* data ) 285 285 { 286 nvpe_scaler_data* datap = ((nvpe_scaler_data*)data->paramters);286 nvpe_scaler_data* datap = reinterpret_cast<nvpe_scaler_data*>( data->paramters ); 287 287 float rate = table->get<float>("rate", 0.0f ); 288 288 datap->adjustment = table->get<vec2>("adjustment", vec2(rate,rate) ); … … 292 292 static void nv_particle_affector_scaler( const particle_affector_data* data, particle* p, float factor, uint32 count ) 293 293 { 294 nvpe_scaler_data* datap = ((nvpe_scaler_data*)data->paramters);294 const nvpe_scaler_data* datap = reinterpret_cast<const nvpe_scaler_data*>( data->paramters ); 295 295 vec2 adjustment = datap->adjustment * factor; 296 296 for ( uint32 i = 0; i < count; ++i ) … … 496 496 info->particles = new particle[ data->quota ]; 497 497 info->quads = new particle_quad[ data->quota ]; 498 info->vtx_array = m_context->create_vertex_array<particle_vtx>( 499 (particle_vtx*)info->quads, data->quota*6, STREAM_DRAW ); 498 info->vtx_array = m_context->create_vertex_array<particle_vtx>( info->quads[0].data, data->quota*6, STREAM_DRAW ); 500 499 info->vtx_buffer = m_context->find_buffer( info->vtx_array, slot::POSITION ); 501 500 info->last_update = m_last_update; … … 691 690 { 692 691 if ( info->count > 0 ) 693 for ( sint32 i = (sint32)info->count-1; i >= 0; --i )692 for ( sint32 i = sint32( info->count ) - 1; i >= 0; --i ) 694 693 { 695 694 particle& pinfo = info->particles[i]; -
trunk/src/fmod/fmod_audio.cc
r399 r406 41 41 if ( info ) 42 42 { 43 FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system;44 FMOD_SOUND* sample = (FMOD_SOUND*)( info->fmod_sound );43 FMOD_SYSTEM* system = static_cast<FMOD_SYSTEM*>( m_system ); 44 FMOD_SOUND* sample = static_cast<FMOD_SOUND*>( info->fmod_sound ); 45 45 FMOD_CHANNEL* channel = nullptr; 46 46 FMOD_RESULT result = FMOD_System_PlaySound( system, FMOD_CHANNEL_FREE, sample, true, &channel ); … … 64 64 if ( info ) 65 65 { 66 FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system;67 FMOD_SOUND* sample = (FMOD_SOUND*)( info->fmod_sound );66 FMOD_SYSTEM* system = static_cast<FMOD_SYSTEM*>( m_system ); 67 FMOD_SOUND* sample = static_cast<FMOD_SOUND*>( info->fmod_sound ); 68 68 FMOD_CHANNEL* channel = nullptr; 69 69 FMOD_RESULT result = FMOD_System_PlaySound( system, FMOD_CHANNEL_FREE, sample, true, &channel ); … … 90 90 nv::sound fmod::audio::load_sound( const string_view& a_path ) 91 91 { 92 FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system;92 FMOD_SYSTEM* system = static_cast<FMOD_SYSTEM*>( m_system ); 93 93 FMOD_SOUND* sample; 94 94 FMOD_RESULT fm_result = FMOD_System_CreateSound( system, a_path.data(), FMOD_3D, 0, &sample ); … … 109 109 if ( info ) 110 110 { 111 FMOD_Sound_Release( (FMOD_SOUND*)info->fmod_sound);111 FMOD_Sound_Release( static_cast<FMOD_SOUND*>( info->fmod_sound ) ); 112 112 m_sounds.destroy( a_sound ); 113 113 } … … 125 125 fmod_up.z = up.z; 126 126 // TODO: we also need to setup orientation! 127 FMOD_System_Set3DListenerAttributes( (FMOD_SYSTEM*)m_system, 0, 0, 0, &fmod_forward, &fmod_up );127 FMOD_System_Set3DListenerAttributes( static_cast<FMOD_SYSTEM*>( m_system ), 0, 0, 0, &fmod_forward, &fmod_up ); 128 128 } 129 129 … … 140 140 // fmod_up.z = 0.0f; 141 141 // TODO: we also need to setup orientation! 142 FMOD_System_Set3DListenerAttributes( (FMOD_SYSTEM*)m_system, 0, &fmod_position, 0, 0, 0 );143 FMOD_System_Update( (FMOD_SYSTEM*)m_system);142 FMOD_System_Set3DListenerAttributes( static_cast<FMOD_SYSTEM*>( m_system ), 0, &fmod_position, 0, 0, 0 ); 143 FMOD_System_Update( static_cast<FMOD_SYSTEM*>( m_system ) ); 144 144 } 145 145 … … 148 148 while ( m_sounds.size() > 0 ) 149 149 release( m_sounds.get_handle(0) ); 150 FMOD_System_Release( (FMOD_SYSTEM*)m_system);150 FMOD_System_Release( static_cast<FMOD_SYSTEM*>( m_system ) ); 151 151 } 152 152 -
trunk/src/formats/assimp_loader.cc
r399 r406 84 84 { 85 85 load_assimp_library(); 86 if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene);86 if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) ); 87 87 m_scene = nullptr; 88 88 m_mesh_count = 0; … … 113 113 void nv::assimp_loader::load_mesh_data( mesh_data* data, size_t index ) 114 114 { 115 const aiScene* scene = (const aiScene*)m_scene;115 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 116 116 const aiMesh* mesh = scene->mMeshes[ index ]; 117 117 data->set_name( mesh->mName.data ); … … 139 139 nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det ); 140 140 if ( skinned ) 141 ((assimp_skinned_vtx*)channel->data)[i] = assimp_skinned_vtx( v, s, n, vt );141 reinterpret_cast< assimp_skinned_vtx* >(channel->data)[i] = assimp_skinned_vtx( v, s, n, vt ); 142 142 else 143 ((assimp_plain_vtx*)channel->data)[i] = assimp_plain_vtx( v, s, n, vt );143 reinterpret_cast< assimp_plain_vtx* >(channel->data)[i] = assimp_plain_vtx( v, s, n, vt ); 144 144 } 145 145 146 146 if ( skinned ) 147 147 { 148 assimp_skinned_vtx* vtx = (assimp_skinned_vtx*)channel->data;148 assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( channel->data ); 149 149 for (unsigned int m=0; m<mesh->mNumBones; m++) 150 150 { … … 154 154 assimp_skinned_vtx& v = vtx[ bone->mWeights[w].mVertexId ]; 155 155 bool found = false; 156 for ( nv::uint32 i = 0 ; i < 4; ++i)156 for ( int i = 0 ; i < 4; ++i ) 157 157 { 158 158 if ( v.boneweight[i] <= 0.0f ) 159 159 { 160 v.boneindex[i] = (int)m;160 v.boneindex[i] = int( m ); 161 161 v.boneweight[i] = bone->mWeights[w].mWeight; 162 162 found = true; … … 171 171 mesh_raw_channel* ichannel = mesh_raw_channel::create_index( USHORT, mesh->mNumFaces * 3 ); 172 172 data->add_channel( ichannel ); 173 uint16* indices = (uint16*)ichannel->data;173 uint16* indices = reinterpret_cast<uint16*>( ichannel->data ); 174 174 for (unsigned int i=0; i<mesh->mNumFaces; i++) 175 175 { … … 177 177 for (unsigned int j=0; j<face->mNumIndices; j++) 178 178 { 179 indices[ i*3 + j ] = (uint16)face->mIndices[j];179 indices[ i*3 + j ] = uint16( face->mIndices[j] ); 180 180 } 181 181 } … … 184 184 nv::assimp_loader::~assimp_loader() 185 185 { 186 if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene);186 if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) ); 187 187 } 188 188 … … 190 190 { 191 191 if ( m_scene == nullptr ) return false; 192 const aiScene* scene = (const aiScene*)m_scene;192 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 193 193 const aiMesh* mesh = scene->mMeshes[ index ]; 194 194 … … 208 208 void nv::assimp_loader::scene_report() const 209 209 { 210 const aiScene* scene = (const aiScene*)m_scene;210 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 211 211 if ( scene == nullptr ) return; 212 212 … … 237 237 aiMesh* mesh = scene->mMeshes[mc]; 238 238 239 NV_LOG_NOTICE( "Mesh #", mc, " - ", string_view( (char*)mesh->mName.data) );239 NV_LOG_NOTICE( "Mesh #", mc, " - ", string_view( static_cast<char*>( mesh->mName.data ) ) ); 240 240 NV_LOG_NOTICE( " bones - ", mesh->mNumBones ); 241 241 NV_LOG_NOTICE( " uvs - ", mesh->mNumUVComponents[0] ); … … 283 283 mesh_nodes_data* nv::assimp_loader::release_merged_bones( mesh_data* meshes ) 284 284 { 285 const aiScene* scene = (const aiScene*)m_scene;285 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 286 286 vector< mesh_node_data > final_bones; 287 287 unordered_map< std::string, uint16 > names; … … 303 303 { 304 304 NV_ASSERT( final_bones.size() < MAX_BONES, "Too many bones to merge!" ); 305 uint16 index = (uint16)final_bones.size();305 uint16 index = uint16( final_bones.size() ); 306 306 final_bones.push_back( bone ); 307 307 names[ bone.name ] = index; … … 316 316 { 317 317 mesh_raw_channel* channel = meshes[m].get_raw_channels()[0]; 318 assimp_skinned_vtx* va = (assimp_skinned_vtx*)channel->data;318 assimp_skinned_vtx* va = reinterpret_cast< assimp_skinned_vtx* >( channel->data ); 319 319 for ( unsigned v = 0; v < channel->count; ++v ) 320 320 { 321 321 assimp_skinned_vtx& vertex = va[v]; 322 322 323 for ( uint32i = 0 ; i < 4; ++i)323 for ( int i = 0 ; i < 4; ++i) 324 324 { 325 325 if ( vertex.boneweight[i] > 0.0f ) 326 326 { 327 vertex.boneindex[i] = (int)translate[vertex.boneindex[i]];327 vertex.boneindex[i] = int( translate[vertex.boneindex[i]] ); 328 328 } 329 329 } … … 340 340 { 341 341 if ( m_scene == nullptr ) return nullptr; 342 const aiScene* scene = (const aiScene*)m_scene;342 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 343 343 if ( scene->mRootNode == nullptr || scene->mAnimations == nullptr || scene->mAnimations[index] == nullptr) return nullptr; 344 344 … … 349 349 mesh_node_data* data = new mesh_node_data[count]; 350 350 351 uint16 frame_rate = (uint16)anim->mTicksPerSecond;352 float duration = (float)anim->mDuration;351 uint16 frame_rate = static_cast<uint16>( anim->mTicksPerSecond ); 352 float duration = static_cast<float>( anim->mDuration ); 353 353 bool flat = false; 354 354 … … 360 360 nv::uint32 nv::assimp_loader::count_nodes( const void* node ) const 361 361 { 362 const aiNode* ainode = (const aiNode*)node;362 const aiNode* ainode = reinterpret_cast< const aiNode* >( node ); 363 363 nv::uint32 count = 1; 364 364 for ( unsigned i = 0; i < ainode->mNumChildren; ++i ) … … 371 371 nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id ) 372 372 { 373 const aiScene* scene = (const aiScene*)m_scene;374 const aiNode* node = (const aiNode*)vnode;373 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 374 const aiNode* node = reinterpret_cast<const aiNode*>( vnode ); 375 375 std::string name( node->mName.data ); 376 376 const aiAnimation* anim = scene->mAnimations[anim_id]; … … 411 411 void nv::assimp_loader::create_keys( mesh_node_data* data, const void* vnode ) 412 412 { 413 const aiNodeAnim* node = (const aiNodeAnim*)vnode;413 const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode ); 414 414 if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 ) 415 415 { … … 424 424 data->data->add_channel( raw_rchannel ); 425 425 //data->data->add_channel( raw_schannel ); 426 assimp_key_p* pchannel = ((assimp_key_p*)(raw_pchannel->data));427 assimp_key_r* rchannel = ((assimp_key_r*)(raw_rchannel->data));426 assimp_key_p* pchannel = reinterpret_cast< assimp_key_p* >( raw_pchannel->data ); 427 assimp_key_r* rchannel = reinterpret_cast< assimp_key_r* >( raw_rchannel->data ); 428 428 //assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data)); 429 429 430 430 for ( unsigned np = 0; np < node->mNumPositionKeys; ++np ) 431 431 { 432 pchannel[np].time = (float)node->mPositionKeys[np].mTime;432 pchannel[np].time = static_cast<float>( node->mPositionKeys[np].mTime ); 433 433 pchannel[np].position = assimp_vec3_cast(node->mPositionKeys[np].mValue); 434 434 } 435 435 for ( unsigned np = 0; np < node->mNumRotationKeys; ++np ) 436 436 { 437 rchannel[np].time = (float)node->mRotationKeys[np].mTime;437 rchannel[np].time = static_cast<float>( node->mRotationKeys[np].mTime ); 438 438 rchannel[np].rotation = assimp_quat_cast(node->mRotationKeys[np].mValue ); 439 439 } … … 463 463 { 464 464 if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr; 465 const aiScene* scene = (const aiScene*)m_scene;465 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 466 466 bool has_bones = false; 467 467 mesh_data* meshes = new mesh_data[ m_mesh_count ]; … … 481 481 { 482 482 if ( m_scene == nullptr ) return 0; 483 const aiScene* scene = (const aiScene*)m_scene;483 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 484 484 return scene->mNumAnimations; 485 485 } -
trunk/src/formats/md2_loader.cc
r395 r406 192 192 // return vec3( v[0], v[1], v[2] ); 193 193 return vec3( v[0], v[2], v[1] ); 194 }195 196 static inline vec3 md2_normal( uint8 normal )197 {198 return md2_vec3( md2_normal_table[normal] );199 194 } 200 195 … … 220 215 md2_loader::~md2_loader() 221 216 { 222 if (m_md2 != nullptr) 223 { 224 free_md2( (md2_t*)(m_md2) ); 225 delete (md2_t*)m_md2; 217 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); 218 if ( md2 != nullptr) 219 { 220 free_md2( md2 ); 221 delete md2; 226 222 } 227 223 } … … 229 225 bool md2_loader::load( stream& source ) 230 226 { 231 m_md2 = (void*)(new md2_t); 232 if ( !read_md2( (md2_t*)m_md2, source ) ) 227 md2_t* md2 = new md2_t; 228 m_md2 = md2; 229 if ( !read_md2( md2, source ) ) 233 230 { 234 231 return false; … … 240 237 nv::size_t md2_loader::get_max_frames() const 241 238 { 242 return static_cast< size_t >( ((md2_t*)m_md2)->header.num_frames );239 return static_cast<size_t>( reinterpret_cast<md2_t*>( m_md2 )->header.num_frames ); 243 240 } 244 241 245 242 void nv::md2_loader::reindex() 246 243 { 247 md2_t* md2 = (md2_t*)m_md2;244 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); 248 245 uint32 num_indexes = static_cast< uint32 >( md2->header.num_tris * 3 ); 249 246 … … 321 318 void nv::md2_loader::release_mesh_frame( mesh_data* data, sint32 frame ) 322 319 { 323 md2_t* md2 = (md2_t*)m_md2;320 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); 324 321 size_t num_frames = static_cast< size_t >( md2->header.num_frames ); 325 322 size_t num_verts = m_new_vindexes.size(); … … 328 325 329 326 mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md2_pn >( num_verts * frame_count ); 330 vtx_md2_pn* vtx_pn = (vtx_md2_pn*)mc_pn->data;327 vtx_md2_pn* vtx_pn = reinterpret_cast< vtx_md2_pn* >( mc_pn->data ); 331 328 332 329 uint32 index = 0; … … 351 348 352 349 mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md2_t >( num_verts ); 353 vtx_md2_t* vtx_t = (vtx_md2_t*)mc_t->data;354 355 vec2 scale( 1.0f / (float) md2->header.skinwidth, 1.0f / (float) md2->header.skinheight);350 vtx_md2_t* vtx_t = reinterpret_cast< vtx_md2_t* >( mc_t->data ); 351 352 vec2 scale( 1.0f / static_cast<float>( md2->header.skinwidth ), 1.0f / static_cast<float>( md2->header.skinheight ) ); 356 353 for (size_t i = 0; i < num_verts; ++i ) 357 354 { … … 363 360 if ( m_new_indexes.size() > 0 ) 364 361 { 365 uint16* icp = (uint16*)ic->data;362 uint16* icp = reinterpret_cast< uint16* >( ic->data ); 366 363 raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp ); 367 364 } -
trunk/src/formats/md3_loader.cc
r399 r406 267 267 nv::md3_loader::~md3_loader() 268 268 { 269 if (m_md3 != nullptr) 270 { 271 free_md3( (md3_t*)(m_md3) ); 272 delete (md3_t*)m_md3; 269 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 270 if ( md3 != nullptr ) 271 { 272 free_md3( md3 ); 273 delete md3; 273 274 } 274 275 } … … 276 277 bool nv::md3_loader::load( stream& source ) 277 278 { 278 m_md3 = (void*)(new md3_t); 279 if ( !read_md3( (md3_t*)m_md3, source ) ) 279 md3_t* md3 = new md3_t; 280 m_md3 = md3; 281 if ( !read_md3( md3, source ) ) 280 282 { 281 283 return false; … … 286 288 nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag ) 287 289 { 288 md3_t* md3 = (md3_t*)m_md3;289 key_raw_channel* result = key_raw_channel::create<md3_key>( (uint32)md3->header.num_frames);290 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 291 key_raw_channel* result = key_raw_channel::create<md3_key>( uint32( md3->header.num_frames ) ); 290 292 // TODO: is this brain damaged in efficiency (loop nest order) or what? 291 293 for ( sint32 f = 0; f < md3->header.num_frames; ++f ) … … 294 296 { 295 297 const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f]; 296 string_view rname( (char*)(rtag.name));298 string_view rname( reinterpret_cast< const char* >(rtag.name) ); 297 299 if (rname == tag) 298 300 { … … 301 303 vec3 axisy ( md3_vec3( rtag.axis[2] ) ); 302 304 vec3 origin ( md3_vec3( rtag.origin ) ); 303 ((md3_key*)(result->data))[f].tform = transform( origin, quat( mat3( axisx, axisy, axisz ) ) );305 reinterpret_cast< md3_key*>(result->data)[f].tform = transform( origin, quat( mat3( axisx, axisy, axisz ) ) ); 304 306 } 305 307 } … … 323 325 { 324 326 mesh_data* data = new mesh_data; 325 release_mesh_frame( data, -1, (sint32)index);327 release_mesh_frame( data, -1, static_cast< sint32 >( index ) ); 326 328 return data; 327 329 } … … 329 331 void nv::md3_loader::release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface ) 330 332 { 331 md3_t* md3 = (md3_t*)m_md3;332 uint32 num_surfaces = (uint32)md3->header.num_surfaces;333 uint32 num_verts = 0;334 uint32 current_frame = ( frame == -1 ? 0 : (uint32)frame );335 uint32 frame_count = ( frame == -1 ? (uint32)md3->header.num_frames : 1 );336 uint32 current_surf = ( surface == -1 ? 0 : (uint32)surface );337 uint32 surf_count = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 );338 uint32 index_count = 0;333 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 334 sint32 num_surfaces = md3->header.num_surfaces; 335 sint32 num_verts = 0; 336 sint32 current_frame = ( frame == -1 ? 0 : frame ); 337 sint32 frame_count = ( frame == -1 ? md3->header.num_frames : 1 ); 338 sint32 current_surf = ( surface == -1 ? 0 : surface ); 339 sint32 surf_count = ( surface == -1 ? md3->header.num_surfaces : 1 ); 340 sint32 index_count = 0; 339 341 340 342 if ( surface >= 0 ) 341 343 { 342 index_count = (uint32)md3->surfaces[(uint32)surface].header.num_triangles * 3;343 num_verts = (uint32)md3->surfaces[(uint32)surface].header.num_verts;344 index_count = md3->surfaces[surface].header.num_triangles * 3; 345 num_verts = md3->surfaces[surface].header.num_verts; 344 346 } 345 347 else 346 for ( uint32 i = 0; i < num_surfaces; ++i )347 { 348 index_count += (uint32)md3->surfaces[i].header.num_triangles * 3;349 num_verts += (uint32)md3->surfaces[i].header.num_verts;350 } 351 352 mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md3_pn >( num_verts * frame_count);353 mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md3_t >( num_verts);354 mesh_raw_channel* ic = mesh_raw_channel::create_index< uint16 >( index_count);355 vtx_md3_pn* vtx_pn = (vtx_md3_pn*)mc_pn->data;356 vtx_md3_t* vtx_t = (vtx_md3_t*) mc_t->data;357 uint16* icp = (uint16*)ic->data;348 for ( sint32 i = 0; i < num_surfaces; ++i ) 349 { 350 index_count += md3->surfaces[i].header.num_triangles * 3; 351 num_verts += md3->surfaces[i].header.num_verts; 352 } 353 354 mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md3_pn >( uint32( num_verts * frame_count ) ); 355 mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md3_t >( uint32( num_verts ) ); 356 mesh_raw_channel* ic = mesh_raw_channel::create_index< uint16 >( uint32( index_count ) ); 357 vtx_md3_pn* vtx_pn = reinterpret_cast< vtx_md3_pn* >( mc_pn->data ); 358 vtx_md3_t* vtx_t = reinterpret_cast< vtx_md3_t* >( mc_t->data ); 359 uint16* icp = reinterpret_cast< uint16* >( ic->data ); 358 360 359 361 uint32 index = 0; … … 387 389 while ( frame_count > 0 ) 388 390 { 389 current_surf = ( surface == -1 ? 0 : (uint32)surface );390 surf_count = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 );391 current_surf = ( surface == -1 ? 0 : surface ); 392 surf_count = ( surface == -1 ? md3->header.num_surfaces : 1 ); 391 393 392 394 while ( surf_count > 0 ) 393 395 { 394 396 md3_surface_t& sface = md3->surfaces[current_surf]; 395 uint32 vcount = (uint32)sface.header.num_verts;396 uint32offset = vcount * current_frame;397 uint32limit = vcount + offset;398 for ( uint32 j = offset; j < limit; ++j )397 sint32 vcount = sface.header.num_verts; 398 sint32 offset = vcount * current_frame; 399 sint32 limit = vcount + offset; 400 for ( sint32 j = offset; j < limit; ++j ) 399 401 { 400 402 md3_vertex_t& v = sface.vertices[j]; … … 410 412 } 411 413 412 data->set_name( (char*)md3->header.name);414 data->set_name( reinterpret_cast< char* >( md3->header.name ) ); 413 415 data->add_channel( mc_pn ); 414 416 data->add_channel( mc_t ); … … 418 420 mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t ) 419 421 { 420 md3_t* md3 = (md3_t*)m_md3;421 uint32 node_count = (uint32)md3->header.num_tags;422 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 423 uint32 node_count = uint32( md3->header.num_tags ); 422 424 if ( node_count == 0 ) return nullptr; 423 425 mesh_node_data* nodes = new mesh_node_data[ node_count ]; … … 425 427 { 426 428 const md3_tag_t& rtag = md3->tags[i]; 427 string_view name( (char*)(rtag.name) );429 string_view name( reinterpret_cast< const char* >(rtag.name) ); 428 430 429 431 nodes[i].transform = mat4(); … … 441 443 mesh_data_pack* nv::md3_loader::release_mesh_data_pack() 442 444 { 443 md3_t* md3 = (md3_t*)m_md3;444 uint32count = 1;445 md3_t* md3 = reinterpret_cast<md3_t*>( m_md3 ); 446 int count = 1; 445 447 mesh_data* data = nullptr; 446 448 if ( m_merge_all ) … … 448 450 data = new mesh_data[1]; 449 451 release_mesh_frame( &data[0], -1, -1 ); 450 data[0].set_name( (char*)md3->header.name);452 data[0].set_name( reinterpret_cast< char* >( md3->header.name ) ); 451 453 } 452 454 else 453 455 { 454 count = (uint32)md3->header.num_surfaces;456 count = md3->header.num_surfaces; 455 457 data = new mesh_data[ count ]; 456 for ( uint32i = 0; i < count; ++i )457 { 458 release_mesh_frame( &data[i], -1, (sint32)i );459 data[i].set_name( (char*)md3->surfaces[i].header.name);460 } 461 } 462 return new mesh_data_pack( count, data, release_mesh_nodes_data() );458 for ( int i = 0; i < count; ++i ) 459 { 460 release_mesh_frame( &data[i], -1, i ); 461 data[i].set_name( reinterpret_cast< char* >( md3->surfaces[i].header.name ) ); 462 } 463 } 464 return new mesh_data_pack( uint32( count ), data, release_mesh_nodes_data() ); 463 465 } 464 466 465 467 nv::size_t md3_loader::get_max_frames() const 466 468 { 467 return static_cast< size_t >( ((md3_t*)m_md3)->header.num_frames );468 } 469 return static_cast<size_t>( reinterpret_cast<md3_t*>( m_md3 )->header.num_frames ); 470 } -
trunk/src/formats/md5_loader.cc
r401 r406 162 162 mesh_raw_channel* ch_t = mesh_raw_channel::create<md5_vtx_t>( num_verts ); 163 163 mesh_raw_channel* ch_pntiw = mesh_raw_channel::create<md5_vtx_pntiw>( num_verts ); 164 tdata = (md5_vtx_t*)ch_t->data;164 tdata = reinterpret_cast< md5_vtx_t* >( ch_t->data ); 165 165 mesh->add_channel( ch_pnt ); 166 166 mesh->add_channel( ch_t ); … … 191 191 192 192 mesh_raw_channel* ch_i = mesh_raw_channel::create_index<uint32>( num_tris * 3 ); 193 uint32* vtx_i = (uint32*)ch_i->data;193 uint32* vtx_i = reinterpret_cast< uint32* >( ch_i->data ); 194 194 uint32 idx = 0; 195 195 mesh->add_channel( ch_i ); … … 199 199 for ( uint32 i = 0; i < num_tris; ++i ) 200 200 { 201 size_tti0;202 size_tti1;203 size_tti2;201 unsigned ti0; 202 unsigned ti1; 203 unsigned ti2; 204 204 205 205 std::getline( sstream, line ); 206 206 sscanf( line.c_str(), "%*s %*u %u %u %u )", &(ti0), &(ti1), &(ti2)); 207 207 208 vtx_i[idx++] = (uint32)ti0;209 vtx_i[idx++] = (uint32)ti1;210 vtx_i[idx++] = (uint32)ti2;208 vtx_i[idx++] = ti0; 209 vtx_i[idx++] = ti1; 210 vtx_i[idx++] = ti2; 211 211 } 212 212 } … … 244 244 assert( nodes == nullptr ); 245 245 nodes = new mesh_node_data[ num_joints ]; 246 m_nodes = new mesh_nodes_data( "md5_animation", num_joints, nodes, (nv::uint16)frame_rate, (float)num_frames, true );246 m_nodes = new mesh_nodes_data( "md5_animation", num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true ); 247 247 joint_infos.resize( num_joints ); 248 248 … … 318 318 { 319 319 sstream >> buf; 320 frame.push_back( (float)atof(buf));320 frame.push_back( static_cast< float >( atof(buf) ) ); 321 321 } 322 322 … … 336 336 { 337 337 assert( m_type == MESH ); 338 md5_vtx_pnt* vtcs = (md5_vtx_pnt*)mdata->get_channel< md5_vtx_pnt >()->data;339 md5_vtx_pntiw* vtx_data = (md5_vtx_pntiw*)mdata->get_channel< md5_vtx_pntiw >()->data;338 md5_vtx_pnt* vtcs = reinterpret_cast< md5_vtx_pnt* >( mdata->get_channel< md5_vtx_pnt >()->data ); 339 md5_vtx_pntiw* vtx_data = reinterpret_cast< md5_vtx_pntiw* >( mdata->get_channel< md5_vtx_pntiw >()->data ); 340 340 341 341 for ( uint32 i = 0; i < vtx_count; ++i ) … … 368 368 } 369 369 370 for ( size_t j = 0; j < 4; ++j )371 { 372 if ( j < weight_count)373 { 374 vdata.boneindex[j] = (int)weights[start_weight + j].joint_id;375 vdata.boneweight[j] = weights[ start_weight+ j].bias;370 for ( int j = 0; j < 4; ++j ) 371 { 372 if ( j < int(weight_count) ) 373 { 374 vdata.boneindex[j] = int( weights[int(start_weight) + j].joint_id ); 375 vdata.boneweight[j] = weights[int(start_weight) + j].bias; 376 376 } 377 377 else … … 396 396 } 397 397 398 const uint32* idata = (uint32*)mdata->get_index_channel()->data;398 const uint32* idata = reinterpret_cast< uint32* >( mdata->get_index_channel()->data ); 399 399 const md5_vtx_t* tdata = mdata->get_channel_data<md5_vtx_t>(); 400 400 … … 448 448 vdata.tangent = vec3(0); 449 449 450 for ( size_t j = 0; j < 4; ++j )450 for ( int j = 0; j < 4; ++j ) 451 451 { 452 452 const mesh_node_data& joint = nodes[vdata.boneindex[j]]; … … 484 484 { 485 485 const mesh_node_data& pjoint = nodes[parent_id]; 486 const transform* ptv = (const transform*)pjoint.data->get_channel(0)->data;486 const transform* ptv = reinterpret_cast< const transform* >( pjoint.data->get_channel(0)->data ); 487 487 transform ptr; 488 488 if ( pjoint.data->get_channel(0)->count > index ) ptr = ptv[ index ]; … … 495 495 } 496 496 497 ((transform*)joint.data->get_channel(0)->data)[index] = transform( pos, orient );497 reinterpret_cast< transform* >( joint.data->get_channel(0)->data )[index] = transform( pos, orient ); 498 498 } 499 499 } -
trunk/src/formats/nmd_loader.cc
r399 r406 174 174 eheader.type = nmd_type::MESH; 175 175 eheader.name = 0; 176 eheader.children = (uint16)data.size();176 eheader.children = static_cast< uint16 >( data.size() ); 177 177 eheader.size = size; 178 178 stream_out.write( &eheader, sizeof( eheader ), 1 ); … … 213 213 header.name = 0; 214 214 header.type = nmd_type::ANIMATION; 215 header.children = (uint16)nodes->get_count();215 header.children = static_cast< uint16 >( nodes->get_count() ); 216 216 header.size = total; 217 217 stream_out.write( &header, sizeof( header ), 1 ); … … 237 237 eheader.type = nmd_type::NODE; 238 238 eheader.name = strings->insert( node->name ); 239 eheader.children = (uint16)chan_count;239 eheader.children = static_cast< uint16 >( chan_count ); 240 240 eheader.size = sizeof( nmd_node_header ) + chan_size; 241 241 stream_out.write( &eheader, sizeof( eheader ), 1 ); -
trunk/src/formats/obj_loader.cc
r395 r406 207 207 virtual void reset() { m_data.clear(); } 208 208 virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); } 209 virtual const uint8* raw_pointer() const { return (const uint8*)m_data.data(); }209 virtual const uint8* raw_pointer() const { return reinterpret_cast< const uint8* >( m_data.data() ); } 210 210 }; 211 211 -
trunk/src/gfx/image.cc
r398 r406 46 46 void image::fill( uint8 value ) 47 47 { 48 raw_fill( m_data, m_data + m_size.x * m_size.y * (int)m_depth, value );48 raw_fill( m_data, m_data + m_size.x * m_size.y * static_cast<int>( m_depth ), value ); 49 49 } 50 50 -
trunk/src/gfx/keyframed_mesh.cc
r395 r406 71 71 if ( m_active ) 72 72 { 73 float tick_time = ( (float)a_anim_time* 0.001f ) * anim->get_frame_rate();73 float tick_time = ( static_cast<float>( a_anim_time ) * 0.001f ) * anim->get_frame_rate(); 74 74 float duration = anim->is_looping() ? anim->get_duration() + 1.0f : anim->get_duration(); 75 75 if ( tick_time >= duration ) … … 82 82 { 83 83 m_active = false; 84 m_last_frame = (uint32)anim->get_end();84 m_last_frame = static_cast<uint32>( anim->get_end() ); 85 85 m_next_frame = m_last_frame; 86 86 m_interpolation = 0.0f; … … 88 88 } 89 89 } 90 m_last_frame = (uint32)( glm::floor( tick_time ) + anim->get_start() );90 m_last_frame = static_cast<uint32>( glm::floor( tick_time ) + anim->get_start() ); 91 91 m_next_frame = m_last_frame + 1; 92 if ( m_next_frame > (uint32)anim->get_end() ) m_next_frame = (uint32)anim->get_start();92 if ( m_next_frame > static_cast<uint32>( anim->get_end() ) ) m_next_frame = static_cast<uint32>( anim->get_start() ); 93 93 m_interpolation = tick_time - glm::floor( tick_time ); 94 94 } … … 152 152 { 153 153 uint32 base_offset = m_next_frame * m_vertex_count * m_vsize; 154 m_context->update_attribute_offset( m_va, (slot)m_loc_next_position, base_offset );155 m_context->update_attribute_offset( m_va, (slot)m_loc_next_normal, base_offset + sizeof( vec3 ) );154 m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_position ), base_offset ); 155 m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_normal ), base_offset + sizeof( vec3 ) ); 156 156 if ( m_has_tangent && m_loc_next_tangent != -1 ) 157 157 { 158 m_context->update_attribute_offset( m_va, (slot)m_loc_next_tangent, base_offset + 2*sizeof( vec3 ) );158 m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_tangent ), base_offset + 2*sizeof( vec3 ) ); 159 159 } 160 160 m_gpu_next_frame = m_next_frame; … … 172 172 m_loc_next_tangent = dev->get_attribute_location( a_program, "nv_next_tangent" ); 173 173 174 m_context->add_vertex_buffer( m_va, (slot)m_loc_next_position, m_pbuffer, FLOAT, 3, 0, m_vsize, false );175 m_context->add_vertex_buffer( m_va, (slot)m_loc_next_normal, m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false );174 m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_position ), m_pbuffer, FLOAT, 3, 0, m_vsize, false ); 175 m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_normal ), m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false ); 176 176 if ( m_has_tangent ) 177 m_context->add_vertex_buffer( m_va, (slot)m_loc_next_tangent, m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );177 m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_tangent ), m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false ); 178 178 } 179 179 keyframed_mesh::update( a_program ); … … 184 184 { 185 185 m_va = m_context->create_vertex_array(); 186 m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );186 m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, m_vchannel->data ); 187 187 m_context->add_vertex_buffers( m_va, m_pbuffer, m_vchannel ); 188 188 189 buffer vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );189 buffer vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), m_mesh_data->get_channel<vertex_t>()->data ); 190 190 m_context->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() ); 191 191 192 buffer ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );192 buffer ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), m_mesh_data->get_index_channel()->data ); 193 193 194 194 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true ); … … 206 206 const vertex_pnt* prev = data + m_vertex_count * m_last_frame; 207 207 const vertex_pnt* next = data + m_vertex_count * m_next_frame; 208 vertex_pnt* vtx = (vertex_pnt*)m_data;208 vertex_pnt* vtx = reinterpret_cast<vertex_pnt*>( m_data ); 209 209 for ( size_t i = 0; i < m_vertex_count; ++i ) 210 210 { … … 219 219 const vertex_pn* prev = data + m_vertex_count * m_last_frame; 220 220 const vertex_pn* next = data + m_vertex_count * m_next_frame; 221 vertex_pn* vtx = (vertex_pn*)m_data;221 vertex_pn* vtx = reinterpret_cast<vertex_pn*>( m_data ); 222 222 223 223 for ( size_t i = 0; i < m_vertex_count; ++i ) -
trunk/src/gfx/mesh_creator.cc
r398 r406 24 24 if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 ) 25 25 { 26 nv_key_transform* channel = ((nv_key_transform*)(keys->get_channel(0)->data));27 nv_key_transform* pchannel = ((nv_key_transform*)(pkeys->get_channel(0)->data));26 nv_key_transform* channel = reinterpret_cast<nv_key_transform*>(keys->get_channel(0)->data); 27 nv_key_transform* pchannel = reinterpret_cast<nv_key_transform*>(pkeys->get_channel(0)->data); 28 28 for ( unsigned n = 0; n < count; ++n ) 29 29 { … … 37 37 { 38 38 m_data->m_frame_rate = 32; 39 m_data->m_duration = (float)max_frames;39 m_data->m_duration = static_cast<float>( max_frames ); 40 40 } 41 41 … … 69 69 key_data* new_keys = new key_data; 70 70 new_keys->add_channel( raw_channel ); 71 nv_key_transform* channel = ((nv_key_transform*)(raw_channel->data));71 nv_key_transform* channel = reinterpret_cast<nv_key_transform*>(raw_channel->data); 72 72 key_descriptor final_key = old_keys->get_final_key(); 73 73 … … 110 110 for ( size_t n = 0; n < channel->count; ++n ) 111 111 { 112 transform_key_raw( channel->desc, (uint8*)(channel->data + n * key_size), scale, r33, ri33 );112 transform_key_raw( channel->desc, channel->data + n * key_size, scale, r33, ri33 ); 113 113 } 114 114 } … … 135 135 switch ( desc.slots[i].vslot ) 136 136 { 137 case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = (int)desc.slots[i].offset; break;138 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = (int)desc.slots[i].offset; break;139 case slot::TANGENT : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = (int)desc.slots[i].offset; break;137 case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = int(desc.slots[i].offset); break; 138 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = int(desc.slots[i].offset); break; 139 case slot::TANGENT : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = int(desc.slots[i].offset); break; 140 140 default : break; 141 141 } … … 144 144 for ( uint32 i = 0; i < channel->count; i++) 145 145 { 146 vec3& p = * ((vec3*)(raw_data + vtx_size*i + p_offset ));146 vec3& p = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + p_offset ); 147 147 p = vertex_transform * p + vertex_offset; 148 148 } … … 151 151 for ( uint32 i = 0; i < channel->count; i++) 152 152 { 153 vec3& n = * ((vec3*)(raw_data + vtx_size*i + n_offset ));153 vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset ); 154 154 n = glm::normalize( normal_transform * n ); 155 155 } … … 157 157 for ( uint32 i = 0; i < channel->count; i++) 158 158 { 159 vec4& t = * ((vec4*)(raw_data + vtx_size*i + t_offset ));159 vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset ); 160 160 t = vec4( glm::normalize( normal_transform * vec3(t) ), t[3] ); 161 161 } … … 173 173 size_t n_offset = 0; 174 174 if ( ch_n == -1 ) return; 175 mesh_raw_channel* channel = m_data->m_channels[ (unsigned) ch_n];175 mesh_raw_channel* channel = m_data->m_channels[ unsigned( ch_n ) ]; 176 176 for ( uint32 i = 0; i < channel->desc.count; ++i ) 177 177 if ( channel->desc.slots[i].vslot == slot::NORMAL ) … … 182 182 for ( uint32 i = 0; i < channel->count; ++i ) 183 183 { 184 vec3& normal = * (vec3*)(channel->data + channel->desc.size * i + n_offset);184 vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.size * i + n_offset ); 185 185 normal = -normal; 186 186 } … … 211 211 if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) 212 212 { 213 p_offset = (int)desc.slots[i].offset;213 p_offset = int( desc.slots[i].offset ); 214 214 p_channel = channel; 215 215 } … … 217 217 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) 218 218 { 219 n_offset = (int)desc.slots[i].offset;219 n_offset = int( desc.slots[i].offset ); 220 220 n_channel = m_data->m_channels[ c ]; 221 221 n_channel_index = c; … … 224 224 case slot::TEXCOORD : if ( desc.slots[i].etype == FLOAT_VECTOR_2 ) 225 225 { 226 t_offset = (int)desc.slots[i].offset;226 t_offset = int( desc.slots[i].offset ); 227 227 t_channel = channel; 228 228 } … … 246 246 247 247 mesh_raw_channel* g_channel = mesh_raw_channel::create<vertex_g>( p_channel->count ); 248 vec4* tangents = (vec4*)g_channel->data;248 vec4* tangents = reinterpret_cast<vec4*>( g_channel->data ); 249 249 vec3* tangents2 = new vec3[ p_channel->count ]; 250 250 uint32 tri_count = i_channel ? i_channel->count / 3 : t_channel->count / 3; … … 259 259 if ( i_type == UINT ) 260 260 { 261 const uint32* idata = (const uint32*)i_channel->data;261 const uint32* idata = reinterpret_cast<const uint32*>( i_channel->data ); 262 262 ti0 = idata[ i * 3 ]; 263 263 ti1 = idata[ i * 3 + 1 ]; … … 266 266 else if ( i_type == USHORT ) 267 267 { 268 const uint16* idata = (const uint16*)i_channel->data;268 const uint16* idata = reinterpret_cast<const uint16*>( i_channel->data ); 269 269 ti0 = idata[ i * 3 ]; 270 270 ti1 = idata[ i * 3 + 1 ]; … … 278 278 } 279 279 280 const vec2& w1 = * ((vec2*)(t_channel->data + t_channel->desc.size*ti0 + t_offset ));281 const vec2& w2 = * ((vec2*)(t_channel->data + t_channel->desc.size*ti1 + t_offset ));282 const vec2& w3 = * ((vec2*)(t_channel->data + t_channel->desc.size*ti2 + t_offset ));280 const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti0 + t_offset ); 281 const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti1 + t_offset ); 282 const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti2 + t_offset ); 283 283 vec2 st1 = w3 - w1; 284 284 vec2 st2 = w2 - w1; … … 291 291 uint32 nti1 = t_channel->count * set + ti1; 292 292 uint32 nti2 = t_channel->count * set + ti2; 293 vec3 v1 = * ((vec3*)(p_channel->data + p_channel->desc.size*nti0 + p_offset ));294 vec3 v2 = * ((vec3*)(p_channel->data + p_channel->desc.size*nti1 + p_offset ));295 vec3 v3 = * ((vec3*)(p_channel->data + p_channel->desc.size*nti2 + p_offset ));293 vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti0 + p_offset ); 294 vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti1 + p_offset ); 295 vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti2 + p_offset ); 296 296 vec3 xyz1 = v3 - v1; 297 297 vec3 xyz2 = v2 - v1; … … 317 317 for ( unsigned int i = 0; i < vtx_count; ++i ) 318 318 { 319 const vec3 n = * ((vec3*)(n_channel->data + n_channel->desc.size*i + n_offset ));319 const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.size*i + n_offset ); 320 320 const vec3 t = vec3(tangents[i]); 321 321 if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) ) … … 420 420 int och_ti = other->get_channel_index( slot::TEXCOORD ); 421 421 if ( ch_pi == -1 || ch_ti == -1 ) return; 422 size_t size = m_data->m_channels[ (unsigned)ch_ti]->count;423 size_t osize = other->m_channels[ (unsigned)och_ti]->count;424 size_t count = m_data->m_channels[ (unsigned)ch_pi]->count;425 size_t ocount = other->m_channels[ (unsigned)och_pi]->count;422 size_t size = m_data->m_channels[ unsigned(ch_ti) ]->count; 423 size_t osize = other->m_channels[ unsigned(och_ti) ]->count; 424 size_t count = m_data->m_channels[ unsigned(ch_pi) ]->count; 425 size_t ocount = other->m_channels[ unsigned(och_pi) ]->count; 426 426 if ( count % size != 0 || ocount % osize != 0 ) return; 427 427 if ( count / size != ocount / osize ) return; … … 440 440 { 441 441 NV_ASSERT( size + osize < uint16(-1), "Index out of range!" ); 442 uint16* indexes = (uint16*)m_data->m_channels[c]->data;443 for ( uint16 i = (uint16)old->count; i < m_data->m_channels[c]->count; ++i )444 indexes[i] += (uint16)size;442 uint16* indexes = reinterpret_cast<uint16*>( m_data->m_channels[c]->data ); 443 for ( uint16 i = uint16( old->count ); i < m_data->m_channels[c]->count; ++i ) 444 indexes[i] += uint16( size ); 445 445 446 446 } … … 448 448 case UINT : 449 449 { 450 uint32* indexes = (uint32*)m_data->m_channels[c]->data;450 uint32* indexes = reinterpret_cast<uint32*>( m_data->m_channels[c]->data ); 451 451 for ( uint32 i = old->count; i < m_data->m_channels[c]->count; ++i ) 452 452 indexes[i] += size; -
trunk/src/gfx/skeletal_mesh.cc
r395 r406 16 16 { 17 17 const mesh_raw_channel* pnt_chan = a_mesh_data->get_channel<md5_vtx_pnt>(); 18 m_pntdata.assign( (const md5_vtx_pnt*)pnt_chan->data, pnt_chan->count );18 m_pntdata.assign( reinterpret_cast<const md5_vtx_pnt*>( pnt_chan->data ), pnt_chan->count ); 19 19 m_bone_offset.resize( bones->get_count() ); 20 20 m_transform.resize( bones->get_count() ); … … 35 35 if ( a_anim ) 36 36 { 37 skeletal_animation_entry_cpu * anim = (skeletal_animation_entry_cpu*)a_anim;38 anim->update_skeleton( m_transform.data(), (float)a_anim_time);37 skeletal_animation_entry_cpu * anim = static_cast<skeletal_animation_entry_cpu*>( a_anim ); 38 anim->update_skeleton( m_transform.data(), static_cast<float>( a_anim_time ) ); 39 39 { 40 40 size_t skeleton_size = m_bone_offset.size(); … … 51 51 const md5_vtx_pntiw& vert = m_vtx_data[i]; 52 52 53 for ( size_t j = 0; j < 4; ++j )53 for ( int j = 0; j < 4; ++j ) 54 54 { 55 unsigned index = (unsigned)vert.boneindex[j];55 unsigned index = unsigned( vert.boneindex[j] ); 56 56 float weight = vert.boneweight[j]; 57 57 const quat& orient = m_transform[index].get_orientation(); … … 71 71 void nv::skeletal_animation_entry_cpu::update_skeleton( transform* skeleton, float time ) const 72 72 { 73 float frame_duration = 1000.f / (float)m_node_data->get_frame_rate();73 float frame_duration = 1000.f / static_cast<float>( m_node_data->get_frame_rate() ); 74 74 float anim_duration = frame_duration * m_node_data->get_duration(); 75 75 float new_time = fmodf( time, anim_duration ) * 0.001f; … … 152 152 if ( bi != bone_names.end() ) 153 153 { 154 bone_id = (sint16)bi->second;154 bone_id = sint16( bi->second ); 155 155 } 156 156 m_bone_ids[n] = bone_id; … … 207 207 if ( m_bone_data && a_anim ) 208 208 { 209 skeletal_animation_entry_gpu * anim = (skeletal_animation_entry_gpu*)a_anim;209 skeletal_animation_entry_gpu * anim = static_cast<skeletal_animation_entry_gpu*>( a_anim ); 210 210 anim->prepare( m_bone_data ); 211 211 anim->update_skeleton( m_transform, a_anim_time ); -
trunk/src/gl/gl_context.cc
r403 r406 91 91 // TODO: support GL_READ_FRAMEBUFFER? 92 92 const gl_framebuffer_info* info = m_framebuffers.get( f ); 93 const gl_texture_info* tinfo = (gl_texture_info*)m_device->get_texture_info( t);93 const gl_texture_info* tinfo = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); 94 94 if ( info ) 95 95 { … … 101 101 // if ( tinfo->size.y == 0 ) 102 102 // glFramebufferTexture1D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+(unsigned)slot, GL_TEXTURE_1D, tinfo->glid, 0 ); 103 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+ (unsigned)slot, gl_type, tinfo->glid, 0 );103 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+unsigned( slot ), gl_type, tinfo->glid, 0 ); 104 104 } 105 105 else 106 106 { 107 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+ (unsigned)slot, gl_type, 0, 0 );107 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+unsigned( slot ), gl_type, 0, 0 ); 108 108 } 109 109 … … 116 116 // TODO: support GL_READ_FRAMEBUFFER? 117 117 const gl_framebuffer_info* info = m_framebuffers.get( f ); 118 const gl_texture_info* tinfo = (gl_texture_info*)m_device->get_texture_info( depth);118 const gl_texture_info* tinfo = static_cast< const gl_texture_info* >( m_device->get_texture_info( depth ) ); 119 119 if ( info ) 120 120 { … … 213 213 void nv::gl_context::bind( program p ) 214 214 { 215 gl_program_info* info = ((gl_device*)m_device)->m_programs.get( p ); 215 gl_device* gdevice = static_cast<gl_device*>( m_device ); 216 gl_program_info* info = gdevice->m_programs.get( p ); 216 217 if ( info ) 217 218 { 218 219 glUseProgram( info->glid ); 219 ((gl_device*)m_device)->update_uniforms( info );220 gdevice->update_uniforms( info ); 220 221 } 221 222 } … … 248 249 } 249 250 250 glVertexAttribPointer( 251 location, 252 static_cast<GLint>( vba.components ), 251 glVertexAttribPointer( 252 location, 253 static_cast<GLint>( vba.components ), 253 254 nv::datatype_to_gl_enum( vba.dtype ), 254 255 GL_FALSE, 255 256 static_cast<GLsizei>( vba.stride ), 256 (void*)vba.offset257 reinterpret_cast<void*>( vba.offset ) 257 258 ); 258 259 } … … 317 318 } 318 319 319 void nv::gl_context::update( texture t, void* data )320 void nv::gl_context::update( texture t, const void* data ) 320 321 { 321 322 const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); … … 327 328 328 329 glBindTexture( gl_type, info->glid ); 329 glTexImage2D( gl_type, 0, (GLint)nv::image_format_to_internal_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );330 glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data ); 330 331 } 331 332 } … … 338 339 GLenum glenum = buffer_type_to_enum( info->type ); 339 340 glBindBuffer( glenum, info->glid ); 340 glBufferSubData( glenum, (GLintptr)offset, (GLsizeiptr)size, data );341 glBufferSubData( glenum, GLintptr( offset ), GLsizeiptr( size ), data ); 341 342 } 342 343 } … … 700 701 void nv::gl_context::apply_engine_uniforms( program p, const scene_state& s ) 701 702 { 702 gl_program_info* info = ((gl_device*)m_device)->m_programs.get( p );703 gl_program_info* info = static_cast<gl_device*>( m_device )->m_programs.get( p ); 703 704 if ( info ) 704 705 { … … 725 726 if ( slots[i] > OUTPUT_7 ) buffers[i] = 0; 726 727 } 727 glDrawBuffers( (GLsizei)count, buffers );728 glDrawBuffers( GLsizei( count ), buffers ); 728 729 } 729 730 -
trunk/src/gl/gl_device.cc
r403 r406 53 53 assert( image->format->BytesPerPixel > 2 ); 54 54 image_format format(image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE ); 55 image_data* data = new image_data( format, ivec2( image->w, image->h ), (nv::uint8*)image->pixels);55 image_data* data = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) ); 56 56 return data; 57 57 } … … 62 62 { 63 63 load_sdl_image_library(); 64 SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, (int)size), 1, "png" );64 SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( const_cast<uint8*>( data ), int( size ) ), 1, "png" ); 65 65 if ( !image ) 66 66 { … … 71 71 assert( image->format->BytesPerPixel > 2 ); 72 72 image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE ); 73 image_data* idata = new image_data( format, ivec2( image->w, image->h ), ( nv::uint8* )image->pixels);73 image_data* idata = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) ); 74 74 return idata; 75 75 } … … 86 86 } 87 87 88 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data /*= nullptr */ )88 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ ) 89 89 { 90 90 unsigned glid = 0; … … 106 106 } 107 107 108 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, (int)nv::sampler_filter_to_enum( asampler.filter_min) );109 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, (int)nv::sampler_filter_to_enum( asampler.filter_max) );110 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, (int)nv::sampler_wrap_to_enum( asampler.wrap_s) );111 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, (int)nv::sampler_wrap_to_enum( asampler.wrap_t) );112 113 glTexImage2D( gl_type, 0, (GLint)nv::image_format_to_internal_enum(aformat.format), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data );108 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 109 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 110 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s) ) ); 111 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t) ) ); 112 113 glTexImage2D( gl_type, 0, GLint( nv::image_format_to_internal_enum(aformat.format) ), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data ); 114 114 115 115 glBindTexture( gl_type, 0 ); … … 163 163 164 164 glBindBuffer( glenum, glid ); 165 glBufferData( glenum, (GLsizeiptr)size, source, buffer_hint_to_enum( hint ) );165 glBufferData( glenum, GLsizeiptr( size ), source, buffer_hint_to_enum( hint ) ); 166 166 glBindBuffer( glenum, 0 ); 167 167 … … 325 325 switch( ubase->get_type() ) 326 326 { 327 case FLOAT : glUniform1fv( uloc, ubase->get_length(), ((uniform< enum_to_type< FLOAT >::type >*)( ubase ))->get_value() ); break;328 case INT : glUniform1iv( uloc, ubase->get_length(), ((uniform< enum_to_type< INT >::type >*)( ubase ))->get_value() ); break;329 case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*)( ubase ))->get_value()); break;330 case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*)( ubase ))->get_value()); break;331 case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*)( ubase ))->get_value()); break;332 case INT_VECTOR_2 : glUniform2iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_2 >::type >*)( ubase ))->get_value()); break;333 case INT_VECTOR_3 : glUniform3iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_3 >::type >*)( ubase ))->get_value()); break;334 case INT_VECTOR_4 : glUniform4iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_4 >::type >*)( ubase ))->get_value()); break;335 case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*)( ubase ))->get_value()); break;336 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*)( ubase ))->get_value()); break;337 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*)( ubase ))->get_value()); break;327 case FLOAT : glUniform1fv( uloc, ubase->get_length(), static_cast< uniform< enum_to_type< FLOAT >::type >*>( ubase )->get_value() ); break; 328 case INT : glUniform1iv( uloc, ubase->get_length(), static_cast< uniform< enum_to_type< INT >::type >*>( ubase )->get_value() ); break; 329 case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*>( ubase )->get_value())); break; 330 case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*>( ubase )->get_value())); break; 331 case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*>( ubase )->get_value())); break; 332 case INT_VECTOR_2 : glUniform2iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_2 >::type >*>( ubase )->get_value())); break; 333 case INT_VECTOR_3 : glUniform3iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_3 >::type >*>( ubase )->get_value())); break; 334 case INT_VECTOR_4 : glUniform4iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_4 >::type >*>( ubase )->get_value())); break; 335 case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*>( ubase )->get_value())); break; 336 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*>( ubase )->get_value())); break; 337 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*>( ubase )->get_value())); break; 338 338 default : break; // error? 339 339 } … … 348 348 glGetProgramiv( p->glid, GL_ACTIVE_ATTRIBUTES, ¶ms ); 349 349 350 for ( unsigned i = 0; i < (unsigned)params; ++i )350 for ( unsigned i = 0; i < unsigned( params ); ++i ) 351 351 { 352 352 int attr_nlen; … … 377 377 glGetProgramiv( p->glid, GL_ACTIVE_UNIFORMS, ¶ms ); 378 378 379 for ( unsigned i = 0; i < size_t(params); ++i )379 for ( unsigned i = 0; i < unsigned( params ); ++i ) 380 380 { 381 381 int uni_nlen; … … 412 412 413 413 const char* pc = shader_code.data(); 414 int l = (int)shader_code.length();414 int l = int( shader_code.length() ); 415 415 416 416 glShaderSource( glid, 1, &pc, &l ); … … 428 428 if ( compile_ok == 0 ) 429 429 { 430 NV_LOG_ERROR( "Shader #", glid, " error: ", buffer);430 NV_LOG_ERROR( "Shader #", glid, " error: ", string_view( buffer, size_t( length ) ) ); 431 431 } 432 432 else 433 433 { 434 NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", buffer);434 NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", string_view( buffer, size_t( length ) ) ); 435 435 } 436 436 } -
trunk/src/gl/gl_window.cc
r395 r406 15 15 { 16 16 #if NV_PLATFORM == NV_WINDOWS 17 ::SwapBuffers( (HDC)m_hwnd);17 ::SwapBuffers( reinterpret_cast<HDC>( m_hwnd ) ); 18 18 #else 19 19 NV_ASSERT( false, "Native GL context currently only working on Windows!" ); … … 26 26 { 27 27 #if NV_PLATFORM == NV_WINDOWS 28 dynwglDeleteContext( (HGLRC)m_context->get_native_handle() );28 dynwglDeleteContext( reinterpret_cast<HGLRC>( m_context->get_native_handle() ) ); 29 29 #endif 30 30 } … … 40 40 m_input = a_input; 41 41 42 m_handle = (void*)handle;42 m_handle = handle; 43 43 44 44 // TODO: error checking 45 HDC hdc = (HDC)dc;45 HDC hdc = reinterpret_cast<HDC>( dc ); 46 46 47 47 const int wgl_attrib_list[] = … … 103 103 // m_height = (uint16)rect.bottom; 104 104 m_handle = wm->adopt_window( handle ); 105 m_hwnd = ::GetDC( (HWND)handle);105 m_hwnd = ::GetDC( reinterpret_cast<HWND>( handle ) ); 106 106 m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) ); 107 107 #else -
trunk/src/gui/gui_ascii_renderer.cc
r395 r406 18 18 bool clear; 19 19 bool border; 20 charborder_chars[8];20 uchar8 border_chars[8]; 21 21 uint32 border_color; 22 22 uint32 text_color; … … 42 42 } 43 43 else 44 er = (ascii_render_data*)( e->m_render_data );44 er = static_cast< ascii_render_data* >( e->m_render_data ); 45 45 46 46 rectangle abs = e->m_absolute; … … 68 68 er->border_color = uint32( border_color ); 69 69 for ( uint32 i = 0; i < 8 && i < path.length(); ) 70 er->border_chars[i] = path[i];70 er->border_chars[i] = static_cast< uchar8 >( path[i] ); 71 71 } 72 72 } … … 75 75 void ascii_renderer::draw( element* e ) 76 76 { 77 ascii_render_data* er = (ascii_render_data*)( e->m_render_data );77 ascii_render_data* er = static_cast< ascii_render_data* >( e->m_render_data ); 78 78 rectangle abs = e->m_absolute; 79 79 if ( er->clear ) m_terminal->clear( abs ); … … 82 82 for ( int x = 0; x < abs.get_width(); ++x ) 83 83 { 84 m_terminal->print( position( abs.ul.y, abs.ul.x + x ), er->border_color, (unsigned char)er->border_chars[0] );85 m_terminal->print( position( abs.lr.y, abs.ul.x + x ), er->border_color, (unsigned char)er->border_chars[1] );84 m_terminal->print( position( abs.ul.y, abs.ul.x + x ), er->border_color, er->border_chars[0] ); 85 m_terminal->print( position( abs.lr.y, abs.ul.x + x ), er->border_color, er->border_chars[1] ); 86 86 } 87 87 88 88 for ( int y = 0; y < abs.get_height(); ++y ) 89 89 { 90 m_terminal->print( position( abs.ul.y + y, abs.ul.x ), er->border_color, (unsigned char)er->border_chars[2] );91 m_terminal->print( position( abs.ul.y + y, abs.lr.x ), er->border_color, (unsigned char)er->border_chars[3] );90 m_terminal->print( position( abs.ul.y + y, abs.ul.x ), er->border_color, er->border_chars[2] ); 91 m_terminal->print( position( abs.ul.y + y, abs.lr.x ), er->border_color, er->border_chars[3] ); 92 92 } 93 93 94 m_terminal->print( abs.ul, er->border_color, (unsigned char)er->border_chars[4] );95 m_terminal->print( abs.ur(), er->border_color, (unsigned char)er->border_chars[5] );96 m_terminal->print( abs.ll(), er->border_color, (unsigned char)er->border_chars[6] );97 m_terminal->print( abs.lr, er->border_color, (unsigned char)er->border_chars[7] );94 m_terminal->print( abs.ul, er->border_color, er->border_chars[4] ); 95 m_terminal->print( abs.ur(), er->border_color, er->border_chars[5] ); 96 m_terminal->print( abs.ll(), er->border_color, er->border_chars[6] ); 97 m_terminal->print( abs.lr, er->border_color, er->border_chars[7] ); 98 98 } 99 99 if ( !e->m_text.empty() ) … … 102 102 for ( char c : e->m_text ) 103 103 { 104 m_terminal->print( p, er->text_color, (unsigned char)c);104 m_terminal->print( p, er->text_color, static_cast< unsigned char >( c ) ); 105 105 ++p.x; 106 106 } -
trunk/src/gui/gui_gfx_renderer.cc
r395 r406 190 190 { 191 191 std::string id_name( filename ); 192 char buffer[8]; size_t len = nv::sint32_to_buffer( (sint32)size, buffer );192 char buffer[8]; size_t len = nv::sint32_to_buffer( sint32( size ), buffer ); 193 193 id_name.append( std::string( buffer, len ) ); 194 194 auto i = m_font_names.find( id_name ); … … 197 197 return i->second; 198 198 } 199 size_t result = (size_t)m_fonts.size();200 texture_font* f = new texture_font( &m_atlas, filename.c_str(), (float)size);199 size_t result = m_fonts.size(); 200 texture_font* f = new texture_font( &m_atlas, filename.c_str(), static_cast<float>( size ) ); 201 201 f->load_glyphs( "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " ); 202 202 m_fonts.push_back( f ); … … 228 228 void gfx_renderer::redraw( element* e, uint32 ) 229 229 { 230 screen_render_data* sr = (screen_render_data*)m_render_data;230 screen_render_data* sr = reinterpret_cast< screen_render_data* >( m_render_data ); 231 231 if ( e->m_render_data == nullptr ) 232 232 { 233 233 e->m_render_data = new element_render_data( &sr->buffer ); 234 234 } 235 element_render_data* er = (element_render_data*)( e->m_render_data );235 element_render_data* er = reinterpret_cast< element_render_data* >( e->m_render_data ); 236 236 size_t size_before = er->buffer.data().size(); 237 237 … … 318 318 if ( m_style.get( e, "text_color", selector, color ) && m_style.get( e, "text_font", selector, path ) && m_style.get( e, "text_size", selector, border ) ) 319 319 { 320 size_t font_id = load_font( path, (uint16)border);320 size_t font_id = load_font( path, size_t( border ) ); 321 321 texture_font* font = get_font( font_id ); 322 322 position p = abs.ul + position( 0, border ); … … 361 361 void gfx_renderer::draw( element* e ) 362 362 { 363 element_render_data* er = (element_render_data*)( e->m_render_data );363 element_render_data* er = reinterpret_cast< element_render_data* >( e->m_render_data ); 364 364 er->buffer.commit(); 365 365 } … … 367 367 void gfx_renderer::draw() 368 368 { 369 screen_render_data* sr = (screen_render_data*)m_render_data;369 screen_render_data* sr = reinterpret_cast< screen_render_data* >( m_render_data ); 370 370 371 371 if ( m_reupload ) 372 372 { 373 m_context->update( sr->tex, (void*)m_atlas.get_data() );373 m_context->update( sr->tex, m_atlas.get_data() ); 374 374 m_reupload = false; 375 375 } … … 392 392 if ( m_render_data ) 393 393 { 394 m_context->get_device()->release( ( (screen_render_data*)m_render_data )->tex );394 m_context->get_device()->release( reinterpret_cast< screen_render_data* >( m_render_data )->tex ); 395 395 delete m_render_data; 396 396 } -
trunk/src/gui/gui_style.cc
r395 r406 34 34 if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), cselector, centry, LUA_TTABLE ) ) return false; 35 35 vec = vec4(); 36 for ( size_t i = 0; i < 4; ++i )36 for ( int i = 0; i < 4; ++i ) 37 37 { 38 lua_rawgeti( m_lua, -1, static_cast<int>( i+1 ));38 lua_rawgeti( m_lua, -1, i+1 ); 39 39 if ( lua_isnil( m_lua, -1 ) ) return true; 40 vec[i] = (float)lua_tonumber( m_lua, -1);40 vec[i] = static_cast< float >( lua_tonumber( m_lua, -1 ) ); 41 41 lua_pop( m_lua, 1 ); 42 42 } -
trunk/src/io/c_stream.cc
r395 r406 31 31 if ( m_file ) 32 32 { 33 ::fclose( (FILE*)m_file);33 ::fclose( reinterpret_cast<FILE*>( m_file ) ); 34 34 } 35 35 } … … 38 38 { 39 39 NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to read!" ); 40 return m_file ? ::fread( buffer, size, count, (FILE*)m_file) : 0;40 return m_file ? ::fread( buffer, size, count, reinterpret_cast<FILE*>( m_file ) ) : 0; 41 41 } 42 42 … … 44 44 { 45 45 NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to write!" ); 46 return m_file ? ::fwrite( buffer, size, count, (FILE*)m_file) : 0;46 return m_file ? ::fwrite( buffer, size, count, reinterpret_cast<FILE*>( m_file ) ) : 0; 47 47 } 48 48 49 49 bool c_stream::seek( long offset, origin orig ) 50 50 { 51 return m_file != nullptr && ( ::fseek( (FILE*)m_file, (long)offset, static_cast<int>(orig) ) == 0 );51 return m_file != nullptr && ( ::fseek( reinterpret_cast<FILE*>( m_file ), offset, static_cast<int>(orig) ) == 0 ); 52 52 } 53 53 54 54 nv::size_t c_stream::tell() 55 55 { 56 return m_file != nullptr ? static_cast< nv::size_t >( ::ftell( (FILE*)m_file) ) : 0;56 return m_file != nullptr ? static_cast< nv::size_t >( ::ftell( reinterpret_cast<FILE*>( m_file ) ) ) : 0; 57 57 } 58 58 … … 72 72 return 0; 73 73 } 74 m_file_size = (size_t)(fstat.st_size);74 m_file_size = static_cast<size_t>(fstat.st_size); 75 75 } 76 76 … … 82 82 if ( m_file != nullptr ) 83 83 { 84 ::fflush( (FILE*)m_file);84 ::fflush( reinterpret_cast<FILE*>( m_file ) ); 85 85 } 86 86 } -
trunk/src/io/string_table.cc
r395 r406 22 22 uint32 cs_size = s.size() + 1; 23 23 NV_ASSERT( m_offsets.size() < index(-1), "Too many strings!" ); 24 index result = (index)m_offsets.size();24 index result = index( m_offsets.size() ); 25 25 size_t dsize = m_data.size(); 26 26 m_offsets.push_back( dsize ); … … 37 37 raw_copy( m_offsets.begin(), m_offsets.end(), offsets ); 38 38 raw_copy( m_data.begin(), m_data.end(), data ); 39 return new string_table( data, m_data.size(), offsets, (index)m_offsets.size() );39 return new string_table( data, m_data.size(), offsets, index( m_offsets.size() ) ); 40 40 } 41 41 42 42 void nv::string_table_creator::dump( nv::stream* out ) const 43 43 { 44 index count = (index)m_offsets.size();44 index count = index( m_offsets.size() ); 45 45 uint32 size = m_data.size(); 46 46 out->write( &count, sizeof( count ), 1 ); -
trunk/src/lib/assimp.cc
r395 r406 35 35 assimp_library.open( path ); 36 36 37 # define NV_ASSIMP_FUN( rtype, fname, fparams ) *(void **) (&fname) = assimp_library.get(#fname);37 # define NV_ASSIMP_FUN( rtype, fname, fparams ) void_assign( fname, assimp_library.get(#fname) ); 38 38 # include <nv/lib/detail/assimp_functions.inc> 39 39 # undef NV_ASSIMP_FUN -
trunk/src/lib/curses.cc
r395 r406 22 22 curses_library.open( path ); 23 23 24 # define NV_CURSES_FUN( rtype, fname, fparams ) *(void **) (&::fname) = curses_library.get(#fname);24 # define NV_CURSES_FUN( rtype, fname, fparams ) void_assign( ::fname, curses_library.get(#fname) ); 25 25 # include <nv/lib/detail/curses_functions.inc> 26 26 # undef NV_CURSES_FUN -
trunk/src/lib/fmod.cc
r395 r406 125 125 fmod_library.open( path ); 126 126 127 # define NV_FMOD_FUN( rtype, fname, fparams ) *(void **) (&fname) = fmod_library.get(#fname);127 # define NV_FMOD_FUN( rtype, fname, fparams ) void_assign( fname, fmod_library.get(#fname) ); 128 128 # include <nv/lib/detail/fmod_functions.inc> 129 129 # undef NV_FMOD_FUN -
trunk/src/lib/freetype2.cc
r395 r406 21 21 freetype_library.open( path ); 22 22 23 # define NV_FREETYPE_FUN( rtype, fname, fparams ) *(void **) (&fname) = freetype_library.get(#fname);23 # define NV_FREETYPE_FUN( rtype, fname, fparams ) void_assign( fname, freetype_library.get(#fname) ); 24 24 # include <nv/lib/detail/freetype2_functions.inc> 25 25 # undef NV_FREETYPE_FUN -
trunk/src/lib/gl.cc
r395 r406 82 82 if ( gl_library_loaded && !force_reload ) return true; 83 83 #if defined( NV_SDL_GL ) 84 # define NV_GL_LOAD( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);85 # define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);86 *(void **) (&gl_ext_loader) = SDL_GL_GetProcAddress;84 # define NV_GL_LOAD( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) ); 85 # define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) ); 86 void_assign( gl_ext_loader, SDL_GL_GetProcAddress ); 87 87 #else 88 88 if ( !gl_library.is_open() ) gl_library.open( path ); 89 89 90 90 # if NV_PLATFORM == NV_WINDOWS 91 # define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);92 *(void **) (&gl_ext_loader) = gl_library.get("wglGetProcAddress");93 # define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_ext_loader(#symbol);91 # define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) ); 92 void_assign( gl_ext_loader, gl_library.get( "wglGetProcAddress" ) ); 93 # define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_ext_loader(#symbol) ); 94 94 # elif (NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE) 95 # define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);96 *(void **) (&gl_ext_loader) = gl_library.get("glXGetProcAddress");97 # define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_ext_loader(#symbol);95 # define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) ); 96 void_assign( gl_ext_loader, gl_library.get("glXGetProcAddress") ); 97 # define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_ext_loader(#symbol) ); 98 98 # else 99 # define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);100 # define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);99 # define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) ); 100 # define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_library.get(#symbol) ); 101 101 # endif 102 102 #endif … … 114 114 } 115 115 116 117 116 118 bool nv::load_wgl_library( const char* path /*= NV_GL_PATH */, bool force_reload ) 117 119 { … … 119 121 #if NV_PLATFORM == NV_WINDOWS 120 122 #if defined( NV_SDL_GL ) 121 # define NV_GL_LOAD( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);122 # define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);123 # define NV_GL_LOAD_REN( fname, rname ) *(void **) (&rname) = SDL_GL_GetProcAddress(#fname);124 (void **) (&gl_ext_loader) = SDL_GL_GetProcAddress;123 # define NV_GL_LOAD( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) ); 124 # define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) ); 125 # define NV_GL_LOAD_REN( fname, rname ) void_assign( rname, SDL_GL_GetProcAddress(#fname) ); 126 void_assign( gl_ext_loader, SDL_GL_GetProcAddress ); 125 127 #else // 126 128 if ( !gl_library.is_open() ) gl_library.open( path ); 127 129 128 *(void **) (&gl_ext_loader) = gl_library.get("wglGetProcAddress");129 #define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);130 #define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_ext_loader(#symbol);131 #define NV_GL_LOAD_REN( fname, rname ) *(void **) (&rname) = gl_library.get(#fname);130 void_assign( gl_ext_loader, gl_library.get("wglGetProcAddress") ); 131 #define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) ); 132 #define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_ext_loader(#symbol) ); 133 #define NV_GL_LOAD_REN( fname, rname ) void_assign( rname, gl_library.get(#fname) ); 132 134 #endif 133 135 # define NV_GL_FUN( rtype, fname, fparams ) NV_GL_LOAD( fname ) … … 161 163 BOOL (NV_GL_APIENTRY *wgl_deletecontext) (HGLRC) = nullptr; 162 164 163 *(void **) &wgl_createcontext = gl_library.get("wglCreateContext");164 *(void **) &wgl_makecurrent = gl_library.get("wglMakeCurrent");165 *(void **) &wgl_deletecontext = gl_library.get("wglDeleteContext");165 void_assign( wgl_createcontext, gl_library.get("wglCreateContext") ); 166 void_assign( wgl_makecurrent, gl_library.get("wglMakeCurrent") ); 167 void_assign( wgl_deletecontext, gl_library.get("wglDeleteContext") ); 166 168 167 169 WNDCLASS wndClass; … … 175 177 wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); 176 178 wndClass.hInstance = hInstance; 177 wndClass.lpfnWndProc = (WNDPROC) DefWindowProc;179 wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>( DefWindowProc ); 178 180 wndClass.lpszClassName = TEXT("Dummy67789"); 179 181 wndClass.lpszMenuName = 0; … … 253 255 254 256 # define NV_GL_FUN_EXT( rtype, symbol, fparams ) \ 255 *(void **) (&symbol) = load_gl_ext_symbol(#symbol, true, nullptr); \257 void_assign( symbol, load_gl_ext_symbol(#symbol, true, nullptr) ); \ 256 258 count++; if ( !symbol ) fail_count++; 257 259 … … 266 268 default : { 267 269 NV_LOG_ERROR( "load_gl_extension - unknown extension \"", name, "\"!" ); 268 return nullptr;270 return false; 269 271 } 270 272 } … … 274 276 { 275 277 NV_LOG_NOTICE( "load_gl_extension - extension \"", name, "\" loaded (", count, " symbols)" ); 276 gl_loaded_extensions = (gl_extensions)( gl_loaded_extensions | (unsigned)extension);278 gl_loaded_extensions = gl_extensions( gl_loaded_extensions | static_cast<unsigned>( extension ) ); 277 279 return false; 278 280 } -
trunk/src/lib/lua.cc
r395 r406 128 128 static const lua_Number *lua_version_51 (lua_State*) 129 129 { 130 static const lua_Number version = (lua_Number)LUA_VERSION_NUM;130 static const lua_Number version = lua_Number( LUA_VERSION_NUM ); 131 131 return &version; 132 132 } … … 227 227 #endif 228 228 229 # define NV_LUA_FUN( rtype, fname, fparams ) *(void **) (&fname) = lua_library.get(#fname);229 # define NV_LUA_FUN( rtype, fname, fparams ) void_assign( fname, lua_library.get(#fname) ); 230 230 # if NV_LUA_VERSION == NV_LUA_52 231 231 # define NV_LUA_FUN_51( rtype, fname, fparams ) … … 246 246 247 247 #if NV_LUA_VERSION == NV_LUA_5C 248 # define NV_LUA_LOAD( fname ) *(void **) (&fname) = lua_library.get(#fname);249 # define NV_LUA_LOAD_AS( fname,fname2 ) *(void **) (&fname) = lua_library.get(#fname2);248 # define NV_LUA_LOAD( fname ) void_assign( fname, lua_library.get(#fname) ); 249 # define NV_LUA_LOAD_AS( fname,fname2 ) void_assign( fname, lua_library.get(#fname2) ); 250 250 bool version_52 = lua_library.try_get("luaL_checkversion_") != nullptr; 251 251 if (version_52) 252 252 { 253 253 # define NV_LUA_COMPAT_FUN( u1, fn, u2, u3, fn2, u5, u6, u7 ) \ 254 *(void **) (&(fn2##_compat)) = lua_library.get(#fn2); \254 void_assign( fn2##_compat, lua_library.get(#fn2) ); \ 255 255 fn = call_##fn2##_compat; 256 256 # include <nv/lib/detail/lua_functions_compat.inc> … … 280 280 { 281 281 # define NV_LUA_COMPAT_FUN( u1, fn, u2, u3, u4, u5, u6, u7 ) \ 282 *(void **) (&fn) = lua_library.get(#fn);282 void_assign(fn, lua_library.get(#fn) ); 283 283 # include <nv/lib/detail/lua_functions_compat.inc> 284 284 # undef NV_LUA_COMPAT_FUN -
trunk/src/lib/sdl.cc
r395 r406 20 20 if ( sdl_library.is_open() ) return true; 21 21 sdl_library.open( path ); 22 # define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_library.get(#fname);22 # define NV_SDL_FUN( rtype, fname, fparams )void_assign( fname, sdl_library.get(#fname) ); 23 23 # include <nv/lib/detail/sdl_functions.inc> 24 24 # undef NV_SDL_FUN -
trunk/src/lib/sdl_image.cc
r395 r406 21 21 sdl_image_library.open( path ); 22 22 23 # define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_image_library.get(#fname);23 # define NV_SDL_FUN( rtype, fname, fparams ) void_assign( fname, sdl_image_library.get(#fname) ); 24 24 # include <nv/lib/detail/sdl_image_functions.inc> 25 25 # undef NV_SDL_FUN -
trunk/src/lib/sdl_mixer.cc
r395 r406 21 21 sdl_mixer_library.open( path ); 22 22 23 # define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_mixer_library.get(#fname);23 # define NV_SDL_FUN( rtype, fname, fparams ) void_assign( fname, sdl_mixer_library.get(#fname) ); 24 24 # include <nv/lib/detail/sdl_mixer_functions.inc> 25 25 # undef NV_SDL_FUN -
trunk/src/lua/lua_function.cc
r395 r406 5 5 // For conditions of distribution and use, see copying.txt file in root folder. 6 6 7 #include <nv/lua/lua_function.hh>7 #include "nv/lua/lua_function.hh" 8 8 9 #include <nv/lua/lua_raw.hh> 9 #include "nv/core/logging.hh" 10 #include "nv/lua/lua_raw.hh" 10 11 11 12 using namespace nv; 13 14 #define NV_LUA_ABORT( func, ... ) \ 15 NV_LOG_CRITICAL( "lua::" func " : ", __VA_ARGS__ ) \ 16 NV_ABORT( "lua::" func " : critical error!" ) 12 17 13 18 lua::function_base::function_base( lua_State* a_L, const path& a_path, bool a_global /*= true*/ ) : L(a_L) … … 16 21 { 17 22 lua_pop( L, 1 ); 18 throw std::runtime_error("not a valid path - " +a_path.to_string() );23 NV_LUA_ABORT( "function_base::function_base", "not a valid path - ", a_path.to_string() ); 19 24 } 20 25 … … 22 27 { 23 28 lua_pop( L, 1 ); 24 throw std::runtime_error("not a valid function - " +a_path.to_string() );29 NV_LUA_ABORT( "function_base::function_base", "not a valid function - ", a_path.to_string() ); 25 30 } 26 31 m_ref = luaL_ref( L, LUA_REGISTRYINDEX ); … … 61 66 std::string error = lua_tostring( L, -1 ); 62 67 lua_pop( L, 1 ); 63 throw std::runtime_error(error.c_str());68 NV_LUA_ABORT( "function_base::call", "call failed - ", error.c_str() ); 64 69 } 65 70 } -
trunk/src/lua/lua_glm.cc
r397 r406 11 11 #include "nv/stl/type_traits/common.hh" 12 12 13 static size_t nlua_swizzel_lookup[256];13 static int nlua_swizzel_lookup[256]; 14 14 15 15 using nv::lua::detail::is_vec; … … 18 18 using nv::lua::detail::push_vec; 19 19 20 inline bool nlua_is_swizzel( const unsigned char* str, size_t max )20 inline bool nlua_is_swizzel( const unsigned char* str, int max ) 21 21 { 22 22 while (*str) … … 155 155 { 156 156 if ( lua_type( L, 1 ) == LUA_TNUMBER ) 157 push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );157 push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) ); 158 158 else 159 159 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 160 push_vec<T>( L, to_vec<T>( L, 1 ) + (typename T::value_type)(lua_tonumber( L, 2 )) );160 push_vec<T>( L, to_vec<T>( L, 1 ) + static_cast<typename T::value_type>(lua_tonumber( L, 2 )) ); 161 161 else 162 162 push_vec<T>( L, to_vec<T>( L, 1 ) + to_vec<T>( L, 2 ) ); … … 168 168 { 169 169 if ( lua_type( L, 1 ) == LUA_TNUMBER ) 170 push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );170 push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) ); 171 171 else 172 172 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 173 push_vec<T>( L, to_vec<T>( L, 1 ) - (typename T::value_type)(lua_tonumber( L, 2 )) );173 push_vec<T>( L, to_vec<T>( L, 1 ) - static_cast<typename T::value_type>(lua_tonumber( L, 2 )) ); 174 174 else 175 175 push_vec<T>( L, to_vec<T>( L, 1 ) - to_vec<T>( L, 2 ) ); … … 181 181 { 182 182 if ( lua_type( L, 1 ) == LUA_TNUMBER ) 183 push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );183 push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) ); 184 184 else 185 185 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 186 push_vec<T>( L, to_vec<T>( L, 1 ) * (typename T::value_type)(lua_tonumber( L, 2 )) );186 push_vec<T>( L, to_vec<T>( L, 1 ) * static_cast<typename T::value_type>(lua_tonumber( L, 2 )) ); 187 187 else 188 188 push_vec<T>( L, to_vec<T>( L, 1 ) * to_vec<T>( L, 2 ) ); … … 194 194 { 195 195 if ( lua_type( L, 1 ) == LUA_TNUMBER ) 196 push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );196 push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) ); 197 197 else 198 198 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 199 push_vec<T>( L, to_vec<T>( L, 1 ) / (typename T::value_type)(lua_tonumber( L, 2 )) );199 push_vec<T>( L, to_vec<T>( L, 1 ) / static_cast<typename T::value_type>(lua_tonumber( L, 2 )) ); 200 200 else 201 201 push_vec<T>( L, to_vec<T>( L, 1 ) / to_vec<T>( L, 2 ) ); … … 226 226 T* v = to_pvec<T>( L, 1 ); 227 227 size_t len = 0; 228 size_t vlen = v->length();229 const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) );230 size_t idx = 255;228 int vlen = v->length(); 229 const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) ); 230 int idx = 255; 231 231 232 232 if ( len == 1 ) … … 264 264 T* v = to_pvec<T>( L, 1 ); 265 265 size_t len = 0; 266 size_t vlen = v->length();267 const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) );268 size_t idx = 255;266 int vlen = v->length(); 267 const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) ); 268 int idx = 255; 269 269 if( len == 1 ) 270 270 { … … 272 272 if ( idx < vlen ) 273 273 { 274 (*v)[idx] = (typename T::value_type)luaL_checknumber( L, 3);274 (*v)[idx] = static_cast<typename T::value_type>( luaL_checknumber( L, 3 ) ); 275 275 return 0; 276 276 } … … 279 279 { 280 280 switch (len) { 281 case 2 : { vec2 v2 = to_vec<vec2>(L,3); for ( size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;282 case 3 : { vec3 v3 = to_vec<vec3>(L,3); for ( size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;283 case 4 : { vec4 v4 = to_vec<vec4>(L,3); for ( size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;281 case 2 : { vec2 v2 = to_vec<vec2>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0; 282 case 3 : { vec3 v3 = to_vec<vec3>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0; 283 case 4 : { vec4 v4 = to_vec<vec4>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0; 284 284 default: break; 285 285 } -
trunk/src/lua/lua_handle.cc
r395 r406 16 16 NV_LUA_STACK_ASSERT( L, +1 ); 17 17 lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table 18 lua_rawgeti( L, -1, (int)index); // table, entry18 lua_rawgeti( L, -1, int( index ) ); // table, entry 19 19 if ( !lua_istable( L, -1 ) ) 20 20 { … … 58 58 lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); 59 59 lua_insert( L, -2 ); 60 lua_rawseti( L, -2, (int)index);60 lua_rawseti( L, -2, int( index ) ); 61 61 lua_pop( L, 1 ); 62 62 } … … 67 67 lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table 68 68 lua_pushinteger( L, 0 ); 69 lua_rawseti( L, -2, (int)index);69 lua_rawseti( L, -2, int( index ) ); 70 70 lua_pop( L, 1 ); 71 71 } -
trunk/src/lua/lua_map_area.cc
r395 r406 67 67 else 68 68 { 69 return * (nv::map_area**)luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE);69 return *reinterpret_cast<nv::map_area**>( luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE ) ); 70 70 } 71 71 return o; … … 88 88 void nv::lua::detail::push_map_area( lua_State* L, nv::map_area* c ) 89 89 { 90 nv::map_area** pm = (nv::map_area**) (lua_newuserdata(L, sizeof(nv::map_area*)));90 nv::map_area** pm = reinterpret_cast<nv::map_area**>( lua_newuserdata(L, sizeof(nv::map_area*) ) ); 91 91 *pm = c; 92 92 luaL_getmetatable( L, NLUA_MAP_AREA_METATABLE ); … … 237 237 lua_rawgeti( L, LUA_REGISTRYINDEX, object_index.get() ); 238 238 lua_pushliteral( L, "__map_area_ptr" ); 239 lua_pushlightuserdata( L, (map_area*)area );239 lua_pushlightuserdata( L, area ); 240 240 lua_rawset( L, -3 ); 241 241 lua_pop( L, 1 ); -
trunk/src/lua/lua_map_tile.cc
r395 r406 40 40 static map_tile* nlua_to_pmap_tile( lua_State* L, int index ) 41 41 { 42 return (map_tile*)luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE);42 return reinterpret_cast<map_tile*>( luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE ) ); 43 43 } 44 44 45 45 static void nlua_push_map_tile( lua_State* L, const map_tile& tile ) 46 46 { 47 map_tile* result = (map_tile*)lua_newuserdata( L, sizeof(map_tile) );47 map_tile* result = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof(map_tile) ) ); 48 48 *result = tile; 49 49 luaL_setmetatable( L, NLUA_MAP_TILE_METATABLE ); … … 65 65 map_tile tile; 66 66 67 tile.size_y = (nv::uint16)( nv::count( code.begin(), code.end(), '\n' ) + 1 );68 tile.size_x = (nv::uint16)( code.find( '\n' ) );67 tile.size_y = nv::uint16( nv::count( code.begin(), code.end(), '\n' ) + 1 ); 68 tile.size_x = nv::uint16( code.find( '\n' ) ); 69 69 if ( tile.size_x == 0 ) 70 70 { 71 tile.size_x = (nv::uint16)code.length();71 tile.size_x = nv::uint16( code.length() ); 72 72 } 73 73 tile.data = new nv::uint8[ tile.size_x * tile.size_y ]; … … 85 85 if ( lua_isstring( L, -2 ) && lua_objlen( L, -2 ) == 1 ) 86 86 { 87 translation[ (nv::uint8)( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );87 translation[ nv::uint8( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) ); 88 88 } 89 89 // removes 'value'; keeps 'key' for next iteration */ … … 95 95 for ( nv::uint16 row = 0; row < tile.size_y; row++ ) 96 96 { 97 nv::uchar8 gylph = (nv::uchar8)code[ row * ( tile.size_x + 1 ) + line ];97 nv::uchar8 gylph = nv::uchar8( code[ row * ( tile.size_x + 1 ) + line ] ); 98 98 // TODO: check for errors 99 99 tile.data[ row * tile.size_x + line ] = translation[ gylph ]; … … 108 108 { 109 109 map_tile* old_tile = nlua_to_pmap_tile( L, 1 ); 110 map_tile* new_tile = (map_tile*) lua_newuserdata( L, sizeof( map_tile) );110 map_tile* new_tile = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof( map_tile ) ) ); 111 111 new_tile->size_x = old_tile->size_x; 112 112 new_tile->size_y = old_tile->size_y; … … 246 246 nv::uint16 org_x = tile->size_x; 247 247 nv::uint16 org_y = tile->size_y; 248 nv::uint16 new_x = ( nv::uint16 )nv::accumulate( sizes_x.begin(), sizes_x.end(), 0);249 nv::uint16 new_y = ( nv::uint16 )nv::accumulate( sizes_y.begin(), sizes_y.end(), 0);248 nv::uint16 new_x = nv::uint16( nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 ) ); 249 nv::uint16 new_y = nv::uint16( nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 ) ); 250 250 251 251 nv::uint8* data = new nv::uint8[ new_x * new_y ]; … … 274 274 static int nlua_map_tile_raw_get( lua_State* L ) 275 275 { 276 map_tile* tile = (map_tile*)lua_touserdata( L, 1);276 map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) ); 277 277 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 278 278 { … … 289 289 static int nlua_map_tile_raw_set( lua_State* L ) 290 290 { 291 map_tile* tile = (map_tile*)lua_touserdata( L, 1);291 map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) ); 292 292 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 293 293 { 294 tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3);294 tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) ); 295 295 } 296 296 else 297 297 { 298 298 nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 ); 299 tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3);299 tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) ); 300 300 } 301 301 return 0; … … 304 304 static int nlua_map_tile_ascii_get( lua_State* L ) 305 305 { 306 map_tile* tile = (map_tile*)lua_touserdata( L, 1);306 map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) ); 307 307 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 308 308 { … … 319 319 static int nlua_map_tile_ascii_set( lua_State* L ) 320 320 { 321 map_tile* tile = (map_tile*)lua_touserdata( L, 1);321 map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) ); 322 322 if ( lua_type( L, 2 ) == LUA_TNUMBER ) 323 323 { 324 tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3);324 tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) ); 325 325 } 326 326 else 327 327 { 328 328 nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 ); 329 tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3);329 tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) ); 330 330 } 331 331 return 0; … … 334 334 static int nlua_map_tile_gc( lua_State* L ) 335 335 { 336 map_tile* tile = (map_tile*)lua_touserdata( L, 1);336 map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) ); 337 337 if ( tile != nullptr ) 338 338 { -
trunk/src/lua/lua_raw.cc
r395 r406 271 271 while ( lua_next( L, index ) != 0 ) 272 272 { 273 result.push_back( (nv::uint8) lua_tointeger( L, -1) );273 result.push_back( static_cast<nv::uint8>( lua_tointeger( L, -1 ) ) ); 274 274 lua_pop( L, 1 ); 275 275 } -
trunk/src/lua/lua_state.cc
r403 r406 258 258 { 259 259 lua_getfield( m_state, -1, element.data() ); 260 float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? (float)lua_tonumber( m_state, -1) : defval;260 float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( m_state, -1 ) ) : defval; 261 261 lua_pop( m_state, 1 ); 262 262 return result; -
trunk/src/rogue/fov_recursive_shadowcasting.cc
r398 r406 25 25 position max_radius = m_size-m_position; 26 26 max_radius = glm::max(max_radius,m_position); 27 m_radius = (int)glm::length((vec2)max_radius)+1;27 m_radius = static_cast<int>( glm::length( vec2( max_radius ) ) )+1; 28 28 } 29 29 m_radius2 = m_radius * m_radius; -
trunk/src/sdl/sdl_audio.cc
r399 r406 36 36 if ( info ) 37 37 { 38 int channel = Mix_PlayChannel(-1, (Mix_Chunk*)( info->sdl_sound), 0);38 int channel = Mix_PlayChannel(-1, static_cast<Mix_Chunk*>( info->sdl_sound ), 0); 39 39 if ( channel == -1 ) 40 40 { … … 43 43 else 44 44 { 45 Mix_Volume( channel, int( volume * 128.0f ) );45 Mix_Volume( channel, static_cast<int>( volume * 128.0f ) ); 46 46 if ( pan != 0.0f) 47 47 { 48 uint8 right = (uint8)( (pan + 1.0f) * 127.0f );48 uint8 right = static_cast<uint8>( (pan + 1.0f) * 127.0f ); 49 49 Mix_SetPanning( channel, 254-right, right ); 50 50 } … … 63 63 if ( info ) 64 64 { 65 int channel = Mix_PlayChannel(-1, (Mix_Chunk*)( info->sdl_sound), 0);65 int channel = Mix_PlayChannel(-1, static_cast<Mix_Chunk*>( info->sdl_sound ), 0); 66 66 if ( channel == -1 ) 67 67 { … … 123 123 if ( info ) 124 124 { 125 Mix_FreeChunk( (Mix_Chunk*)info->sdl_sound);125 Mix_FreeChunk( static_cast<Mix_Chunk*>( info->sdl_sound ) ); 126 126 m_sounds.destroy( a_sound ); 127 127 } -
trunk/src/sdl/sdl_input.cc
r395 r406 25 25 kevent.key.code = KEY_NONE; 26 26 27 uint32 ucode = (uint32)ke.keysym.sym;27 uint32 ucode = static_cast<uint32>( ke.keysym.sym ); 28 28 29 29 // if result is a typable char place it into the structure … … 36 36 int capslock = !!(ke.keysym.mod & KMOD_CAPS); 37 37 if ((shifted ^ capslock) != 0) { 38 kevent.key.ascii = (uchar8)SDL_toupper((int)ucode);38 kevent.key.ascii = static_cast<uchar8>( SDL_toupper( static_cast<int>( ucode ) ) ); 39 39 } 40 40 } -
trunk/src/sdl/sdl_window.cc
r395 r406 64 64 65 65 nv::load_gl_library(); 66 NV_LOG_INFO( "OpenGL Vendor : ", (const char*)glGetString(GL_VENDOR) );67 NV_LOG_INFO( "OpenGL Renderer : ", (const char*)glGetString( GL_RENDERER) );68 NV_LOG_INFO( "OpenGL Version : ", (const char*)glGetString( GL_VERSION) );69 NV_LOG_INFO( "OpenGL GLSL Version : ", (const char*)glGetString( GL_SHADING_LANGUAGE_VERSION) );66 NV_LOG_INFO( "OpenGL Vendor : ", reinterpret_cast<const char*>( glGetString(GL_VENDOR) ) ); 67 NV_LOG_INFO( "OpenGL Renderer : ", reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) ); 68 NV_LOG_INFO( "OpenGL Version : ", reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) ); 69 NV_LOG_INFO( "OpenGL GLSL Version : ", reinterpret_cast<const char*>( glGetString( GL_SHADING_LANGUAGE_VERSION ) ) ); 70 70 SDL_GL_SetSwapInterval(1); 71 71 -
trunk/src/stl/assert.cc
r403 r406 64 64 exit( 1 ); 65 65 } 66 67 68 NV_NORETURN void nv::exit( int ret_val ) 69 { 70 ::exit( ret_val ); 71 }
Note: See TracChangeset
for help on using the changeset viewer.