- Timestamp:
- 06/20/15 00:05:17 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
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.