Changeset 406 for trunk/src


Ignore:
Timestamp:
06/20/15 00:05:17 (10 years ago)
Author:
epyon
Message:
  • code compiles cleanly on maximum warning level
Location:
trunk/src
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/curses/curses_terminal.cc

    r395 r406  
    2020        noecho();
    2121
    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 );
    2525
    2626        start_color();
     
    8989
    9090        // Get value from curses
    91         int result = wgetch((WINDOW*)m_screen);
     91        int result = wgetch( static_cast<WINDOW*>( m_screen ) );
    9292
    9393        // If value is err, return none event
  • trunk/src/engine/particle_engine.cc

    r395 r406  
    194194static bool nv_particle_affector_linear_force_init( lua::table_guard* table, particle_affector_data* data )
    195195{
    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 );
    197197        datap->force_vector = table->get<vec3>("force_vector", vec3() );
    198198        datap->average      = table->get<bool>("average", false );
     
    202202static void nv_particle_affector_linear_force( const particle_affector_data* data, particle* p, float factor, uint32 count )
    203203{
    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 );
    205205        if ( datap->average )
    206206        {
     
    226226static bool nv_particle_affector_deflector_plane_init( lua::table_guard* table, particle_affector_data* data )
    227227{
    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 );
    229229        datap->plane_point  = table->get<vec3>("plane_point",  vec3() );
    230230        datap->plane_normal = table->get<vec3>("plane_normal", vec3(0.0f,1.0f,0.0f) );
     
    237237static void nv_particle_affector_deflector_plane( const particle_affector_data* data, particle* p, float factor, uint32 count )
    238238{
    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 );
    240240        for ( uint32 i = 0; i < count; ++i )
    241241        {
     
    262262static bool nv_particle_affector_color_fader_init( lua::table_guard* table, particle_affector_data* data )
    263263{
    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 );
    265265        datap->adjustment = table->get<vec4>("adjustment",  vec4() );
    266266        return true;
     
    269269static void nv_particle_affector_color_fader( const particle_affector_data* data, particle* p, float factor, uint32 count )
    270270{
    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 );
    272272        vec4 adjustment = datap->adjustment * factor;
    273273        for ( uint32 i = 0; i < count; ++i )
     
    284284static bool nv_particle_affector_scaler_init( lua::table_guard* table, particle_affector_data* data )
    285285{
    286         nvpe_scaler_data* datap = ((nvpe_scaler_data*)data->paramters);
     286        nvpe_scaler_data* datap = reinterpret_cast<nvpe_scaler_data*>( data->paramters );
    287287        float rate        = table->get<float>("rate", 0.0f );
    288288        datap->adjustment = table->get<vec2>("adjustment",  vec2(rate,rate) );
     
    292292static void nv_particle_affector_scaler( const particle_affector_data* data, particle* p, float factor, uint32 count )
    293293{
    294         nvpe_scaler_data* datap = ((nvpe_scaler_data*)data->paramters);
     294        const nvpe_scaler_data* datap = reinterpret_cast<const nvpe_scaler_data*>( data->paramters );
    295295        vec2 adjustment = datap->adjustment * factor;
    296296        for ( uint32 i = 0; i < count; ++i )
     
    496496        info->particles = new particle[ data->quota ];
    497497        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 );
    500499        info->vtx_buffer = m_context->find_buffer( info->vtx_array, slot::POSITION );
    501500        info->last_update = m_last_update;
     
    691690{
    692691        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 )
    694693                {
    695694                        particle& pinfo = info->particles[i];
  • trunk/src/fmod/fmod_audio.cc

    r399 r406  
    4141        if ( info )
    4242        {
    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 );
    4545                FMOD_CHANNEL* channel = nullptr;
    4646                FMOD_RESULT result    = FMOD_System_PlaySound( system, FMOD_CHANNEL_FREE, sample, true, &channel );
     
    6464        if ( info )
    6565        {
    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 );
    6868                FMOD_CHANNEL* channel = nullptr;
    6969                FMOD_RESULT result    = FMOD_System_PlaySound( system, FMOD_CHANNEL_FREE, sample, true, &channel );
     
    9090nv::sound fmod::audio::load_sound( const string_view& a_path )
    9191{
    92         FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system;
     92        FMOD_SYSTEM* system = static_cast<FMOD_SYSTEM*>( m_system );
    9393        FMOD_SOUND* sample;
    9494        FMOD_RESULT fm_result = FMOD_System_CreateSound( system, a_path.data(), FMOD_3D, 0, &sample );
     
    109109        if ( info )
    110110        {
    111                 FMOD_Sound_Release( (FMOD_SOUND*)info->fmod_sound );
     111                FMOD_Sound_Release( static_cast<FMOD_SOUND*>( info->fmod_sound ) );
    112112                m_sounds.destroy( a_sound );
    113113        }
     
    125125        fmod_up.z = up.z;
    126126        // 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 );
    128128}
    129129
     
    140140//      fmod_up.z = 0.0f;
    141141        // 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 ) );
    144144}
    145145
     
    148148        while ( m_sounds.size() > 0 )
    149149                release( m_sounds.get_handle(0) );
    150         FMOD_System_Release( (FMOD_SYSTEM*)m_system );
     150        FMOD_System_Release( static_cast<FMOD_SYSTEM*>( m_system ) );
    151151}
    152152
  • trunk/src/formats/assimp_loader.cc

    r399 r406  
    8484{
    8585        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 ) );
    8787        m_scene = nullptr;
    8888        m_mesh_count = 0;
     
    113113void nv::assimp_loader::load_mesh_data( mesh_data* data, size_t index )
    114114{
    115         const aiScene* scene = (const aiScene*)m_scene;
     115        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    116116        const aiMesh*  mesh  = scene->mMeshes[ index ];
    117117        data->set_name( mesh->mName.data );
     
    139139                nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det );
    140140                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 );
    142142                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 );
    144144        }
    145145
    146146        if ( skinned )
    147147        {
    148                 assimp_skinned_vtx* vtx = (assimp_skinned_vtx*)channel->data;
     148                assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( channel->data );
    149149                for (unsigned int m=0; m<mesh->mNumBones; m++)
    150150                {
     
    154154                                assimp_skinned_vtx& v = vtx[ bone->mWeights[w].mVertexId ];
    155155                                bool found = false;
    156                                 for (nv::uint32 i = 0 ; i < 4; ++i)
     156                                for ( int i = 0 ; i < 4; ++i )
    157157                                {
    158158                                        if ( v.boneweight[i] <= 0.0f )
    159159                                        {
    160                                                 v.boneindex[i]  = (int)m;
     160                                                v.boneindex[i]  = int( m );
    161161                                                v.boneweight[i] = bone->mWeights[w].mWeight;
    162162                                                found = true;
     
    171171        mesh_raw_channel* ichannel = mesh_raw_channel::create_index( USHORT, mesh->mNumFaces * 3 );
    172172        data->add_channel( ichannel );
    173         uint16* indices = (uint16*)ichannel->data;
     173        uint16* indices = reinterpret_cast<uint16*>( ichannel->data );
    174174        for (unsigned int i=0; i<mesh->mNumFaces; i++)
    175175        {
     
    177177                for (unsigned int j=0; j<face->mNumIndices; j++)
    178178                {
    179                         indices[ i*3 + j ] = (uint16)face->mIndices[j];
     179                        indices[ i*3 + j ] = uint16( face->mIndices[j] );
    180180                }
    181181        }
     
    184184nv::assimp_loader::~assimp_loader()
    185185{
    186         if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene );
     186        if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) );
    187187}
    188188
     
    190190{
    191191        if ( m_scene == nullptr ) return false;
    192         const aiScene* scene = (const aiScene*)m_scene;
     192        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    193193        const aiMesh*  mesh  = scene->mMeshes[ index ];
    194194
     
    208208void nv::assimp_loader::scene_report() const
    209209{
    210         const aiScene* scene = (const aiScene*)m_scene;
     210        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    211211        if ( scene == nullptr ) return;
    212212
     
    237237                        aiMesh* mesh = scene->mMeshes[mc];
    238238
    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 ) ) );
    240240                        NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
    241241                        NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
     
    283283mesh_nodes_data* nv::assimp_loader::release_merged_bones( mesh_data* meshes )
    284284{
    285         const aiScene* scene = (const aiScene*)m_scene;
     285        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    286286        vector< mesh_node_data > final_bones;
    287287        unordered_map< std::string, uint16 > names;
     
    303303                                {
    304304                                        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() );
    306306                                        final_bones.push_back( bone );
    307307                                        names[ bone.name ] = index;
     
    316316                        {
    317317                                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 );
    319319                                for ( unsigned v = 0; v < channel->count; ++v )
    320320                                {
    321321                                        assimp_skinned_vtx& vertex = va[v];
    322322
    323                                         for (uint32 i = 0 ; i < 4; ++i)
     323                                        for ( int i = 0 ; i < 4; ++i)
    324324                                        {
    325325                                                if ( vertex.boneweight[i] > 0.0f )
    326326                                                {
    327                                                         vertex.boneindex[i] = (int)translate[vertex.boneindex[i]];
     327                                                        vertex.boneindex[i] = int( translate[vertex.boneindex[i]] );
    328328                                                }
    329329                                        }
     
    340340{
    341341        if ( m_scene == nullptr ) return nullptr;
    342         const aiScene* scene = (const aiScene*)m_scene;
     342        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    343343        if ( scene->mRootNode == nullptr || scene->mAnimations == nullptr || scene->mAnimations[index] == nullptr) return nullptr;
    344344
     
    349349        mesh_node_data* data    = new mesh_node_data[count];
    350350
    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 );
    353353        bool   flat           = false;
    354354
     
    360360nv::uint32 nv::assimp_loader::count_nodes( const void* node ) const
    361361{
    362         const aiNode* ainode = (const aiNode*)node;
     362        const aiNode* ainode = reinterpret_cast< const aiNode* >( node );
    363363        nv::uint32 count = 1;
    364364        for ( unsigned i = 0; i < ainode->mNumChildren; ++i )
     
    371371nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id )
    372372{
    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 );
    375375        std::string name( node->mName.data );
    376376        const aiAnimation* anim  = scene->mAnimations[anim_id];
     
    411411void nv::assimp_loader::create_keys( mesh_node_data* data, const void* vnode )
    412412{
    413         const aiNodeAnim* node = (const aiNodeAnim*)vnode;
     413        const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode );
    414414        if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 )
    415415        {
     
    424424        data->data->add_channel( raw_rchannel );
    425425        //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 );
    428428        //assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data));
    429429
    430430        for ( unsigned np = 0; np < node->mNumPositionKeys; ++np )
    431431        {
    432                 pchannel[np].time     = (float)node->mPositionKeys[np].mTime;
     432                pchannel[np].time     = static_cast<float>( node->mPositionKeys[np].mTime );
    433433                pchannel[np].position = assimp_vec3_cast(node->mPositionKeys[np].mValue);
    434434        }
    435435        for ( unsigned np = 0; np < node->mNumRotationKeys; ++np )
    436436        {
    437                 rchannel[np].time     = (float)node->mRotationKeys[np].mTime;
     437                rchannel[np].time     = static_cast<float>( node->mRotationKeys[np].mTime );
    438438                rchannel[np].rotation = assimp_quat_cast(node->mRotationKeys[np].mValue );
    439439        }
     
    463463{
    464464        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 );
    466466        bool has_bones = false;
    467467        mesh_data* meshes = new mesh_data[ m_mesh_count ];
     
    481481{
    482482        if ( m_scene == nullptr ) return 0;
    483         const aiScene* scene = (const aiScene*)m_scene;
     483        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    484484        return scene->mNumAnimations;   
    485485}
  • trunk/src/formats/md2_loader.cc

    r395 r406  
    192192        //      return vec3( v[0], v[1], v[2] );
    193193        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] );
    199194}
    200195
     
    220215md2_loader::~md2_loader()
    221216{
    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;
    226222        }
    227223}
     
    229225bool md2_loader::load( stream& source )
    230226{
    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 ) )
    233230        {
    234231                return false;
     
    240237nv::size_t md2_loader::get_max_frames() const
    241238{
    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 );
    243240}
    244241
    245242void nv::md2_loader::reindex()
    246243{
    247         md2_t* md2 = (md2_t*)m_md2;
     244        md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
    248245        uint32 num_indexes = static_cast< uint32 >( md2->header.num_tris * 3 );
    249246
     
    321318void nv::md2_loader::release_mesh_frame( mesh_data* data, sint32 frame )
    322319{
    323         md2_t* md2 = (md2_t*)m_md2;
     320        md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
    324321        size_t num_frames = static_cast< size_t >( md2->header.num_frames );
    325322        size_t num_verts  =     m_new_vindexes.size();
     
    328325
    329326        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 );
    331328
    332329        uint32 index = 0;
     
    351348
    352349        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 ) );
    356353        for (size_t i = 0; i < num_verts; ++i )
    357354        {
     
    363360        if ( m_new_indexes.size() > 0 )
    364361        {
    365                 uint16* icp = (uint16*)ic->data;
     362                uint16* icp = reinterpret_cast< uint16* >( ic->data );
    366363                raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp );
    367364        }
  • trunk/src/formats/md3_loader.cc

    r399 r406  
    267267nv::md3_loader::~md3_loader()
    268268{
    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;
    273274        }
    274275}
     
    276277bool nv::md3_loader::load( stream& source )
    277278{
    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 ) )
    280282        {
    281283                return false;
     
    286288nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag )
    287289{
    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 ) );
    290292        // TODO: is this brain damaged in efficiency (loop nest order) or what?
    291293        for ( sint32 f = 0; f < md3->header.num_frames; ++f )
     
    294296                {
    295297                        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) );
    297299                        if (rname == tag)
    298300                        {
     
    301303                                vec3 axisy  ( md3_vec3( rtag.axis[2] ) );
    302304                                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 ) ) );
    304306                        }
    305307                }
     
    323325{
    324326        mesh_data* data = new mesh_data;
    325         release_mesh_frame( data, -1, (sint32)index );
     327        release_mesh_frame( data, -1, static_cast< sint32 >( index ) );
    326328        return data;
    327329}
     
    329331void nv::md3_loader::release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface )
    330332{
    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;
    339341
    340342        if ( surface >= 0 )
    341343        {
    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;
    344346        }
    345347        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 );
    358360
    359361        uint32 index  = 0;
     
    387389        while ( frame_count > 0 )
    388390        {
    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 );
    391393
    392394                while ( surf_count > 0 )
    393395                {
    394396                        md3_surface_t& sface  = md3->surfaces[current_surf];
    395                         uint32         vcount = (uint32)sface.header.num_verts;
    396                         uint32        offset = vcount * current_frame;
    397                         uint32        limit  = 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 )
    399401                        {
    400402                                md3_vertex_t& v = sface.vertices[j];
     
    410412        }
    411413
    412         data->set_name( (char*)md3->header.name );
     414        data->set_name( reinterpret_cast< char* >( md3->header.name ) );
    413415        data->add_channel( mc_pn );
    414416        data->add_channel( mc_t );
     
    418420mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t )
    419421{
    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 );
    422424        if ( node_count == 0 ) return nullptr;
    423425        mesh_node_data* nodes = new mesh_node_data[ node_count ];
     
    425427        {
    426428                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) );
    428430
    429431                nodes[i].transform = mat4();
     
    441443mesh_data_pack* nv::md3_loader::release_mesh_data_pack()
    442444{
    443         md3_t* md3 = (md3_t*)m_md3;
    444         uint32 count = 1;
     445        md3_t* md3 = reinterpret_cast<md3_t*>( m_md3 );
     446        int count = 1;
    445447        mesh_data* data = nullptr;
    446448        if ( m_merge_all )
     
    448450                data = new mesh_data[1];
    449451                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 ) );
    451453        }
    452454        else
    453455        {
    454                 count = (uint32)md3->header.num_surfaces;
     456                count = md3->header.num_surfaces;
    455457                data = new mesh_data[ count ];
    456                 for ( uint32 i = 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() );
    463465}
    464466
    465467nv::size_t md3_loader::get_max_frames() const
    466468{
    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  
    162162                                                mesh_raw_channel* ch_t   = mesh_raw_channel::create<md5_vtx_t>( num_verts );
    163163                                                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 );
    165165                                                mesh->add_channel( ch_pnt );
    166166                                                mesh->add_channel( ch_t );
     
    191191
    192192                                        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 );
    194194                                        uint32 idx = 0;
    195195                                        mesh->add_channel( ch_i );
     
    199199                                        for ( uint32 i = 0; i < num_tris; ++i )
    200200                                        {
    201                                                 size_t ti0;
    202                                                 size_t ti1;
    203                                                 size_t ti2;
     201                                                unsigned ti0;
     202                                                unsigned ti1;
     203                                                unsigned ti2;
    204204
    205205                                                std::getline( sstream, line );
    206206                                                sscanf( line.c_str(), "%*s %*u %u %u %u )", &(ti0), &(ti1), &(ti2));
    207207
    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;
    211211                                        }             
    212212                                }
     
    244244                        assert( nodes == nullptr );
    245245                        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 );
    247247                        joint_infos.resize( num_joints );
    248248
     
    318318                        {
    319319                                sstream >> buf;
    320                                 frame.push_back((float)atof(buf));
     320                                frame.push_back( static_cast< float >( atof(buf) ) );
    321321                        }
    322322
     
    336336{
    337337        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 );
    340340
    341341        for ( uint32 i = 0; i < vtx_count; ++i )
     
    368368                }
    369369
    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;
    376376                        }
    377377                        else
     
    396396        }
    397397
    398         const uint32*    idata = (uint32*)mdata->get_index_channel()->data;
     398        const uint32*    idata = reinterpret_cast< uint32* >( mdata->get_index_channel()->data );
    399399        const md5_vtx_t* tdata = mdata->get_channel_data<md5_vtx_t>();
    400400
     
    448448                vdata.tangent  = vec3(0);
    449449 
    450                 for ( size_t j = 0; j < 4; ++j )
     450                for ( int j = 0; j < 4; ++j )
    451451                {
    452452                        const mesh_node_data&  joint = nodes[vdata.boneindex[j]];
     
    484484                {
    485485                        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 );
    487487                        transform ptr;
    488488                        if ( pjoint.data->get_channel(0)->count > index ) ptr = ptv[ index ];
     
    495495                }
    496496
    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 );
    498498        }
    499499}
  • trunk/src/formats/nmd_loader.cc

    r399 r406  
    174174        eheader.type     = nmd_type::MESH;
    175175        eheader.name     = 0;
    176         eheader.children = (uint16)data.size();
     176        eheader.children = static_cast< uint16 >( data.size() );
    177177        eheader.size     = size;
    178178        stream_out.write( &eheader, sizeof( eheader ), 1 );
     
    213213        header.name     = 0;
    214214        header.type     = nmd_type::ANIMATION;
    215         header.children = (uint16)nodes->get_count();
     215        header.children = static_cast< uint16 >( nodes->get_count() );
    216216        header.size     = total;
    217217        stream_out.write( &header, sizeof( header ), 1 );
     
    237237                eheader.type     = nmd_type::NODE;
    238238                eheader.name     = strings->insert( node->name );
    239                 eheader.children = (uint16)chan_count;
     239                eheader.children = static_cast< uint16 >( chan_count );
    240240                eheader.size     = sizeof( nmd_node_header ) + chan_size;
    241241                stream_out.write( &eheader, sizeof( eheader ), 1 );
  • trunk/src/formats/obj_loader.cc

    r395 r406  
    207207        virtual void reset() { m_data.clear(); }
    208208        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() ); }
    210210};
    211211
  • trunk/src/gfx/image.cc

    r398 r406  
    4646void image::fill( uint8 value )
    4747{
    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 );
    4949}
    5050
  • trunk/src/gfx/keyframed_mesh.cc

    r395 r406  
    7171        if ( m_active )
    7272        {
    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();
    7474                float duration  = anim->is_looping() ? anim->get_duration() + 1.0f : anim->get_duration();
    7575                if ( tick_time >= duration )
     
    8282                        {
    8383                                m_active     = false;
    84                                 m_last_frame = (uint32)anim->get_end();
     84                                m_last_frame = static_cast<uint32>( anim->get_end() );
    8585                                m_next_frame = m_last_frame;
    8686                                m_interpolation = 0.0f;
     
    8888                        }
    8989                }
    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() );
    9191                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() );
    9393                m_interpolation = tick_time - glm::floor( tick_time );
    9494        }
     
    152152        {
    153153                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 ) );
    156156                if ( m_has_tangent && m_loc_next_tangent != -1 )
    157157                {
    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 ) );
    159159                }
    160160                m_gpu_next_frame = m_next_frame;
     
    172172                        m_loc_next_tangent  = dev->get_attribute_location( a_program, "nv_next_tangent" );
    173173
    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 );
    176176                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 );
    178178        }
    179179        keyframed_mesh::update( a_program );
     
    184184{
    185185        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 );
    187187        m_context->add_vertex_buffers( m_va, m_pbuffer, m_vchannel );
    188188
    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 );
    190190        m_context->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() );
    191191
    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 );
    193193
    194194        m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
     
    206206                const vertex_pnt* prev = data + m_vertex_count * m_last_frame;
    207207                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 );
    209209                for ( size_t i = 0; i < m_vertex_count; ++i )
    210210                {
     
    219219                const vertex_pn* prev = data + m_vertex_count * m_last_frame;
    220220                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 );
    222222
    223223                for ( size_t i = 0; i < m_vertex_count; ++i )
  • trunk/src/gfx/mesh_creator.cc

    r398 r406  
    2424                if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 )
    2525                {
    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);
    2828                        for ( unsigned n = 0; n < count; ++n )
    2929                        {
     
    3737        {
    3838                m_data->m_frame_rate = 32;
    39                 m_data->m_duration   = (float)max_frames;
     39                m_data->m_duration   = static_cast<float>( max_frames );
    4040        }
    4141
     
    6969                        key_data* new_keys = new key_data;
    7070                        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);
    7272                        key_descriptor final_key = old_keys->get_final_key();
    7373
     
    110110                                for ( size_t n = 0; n < channel->count; ++n )
    111111                                {
    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 );
    113113                                }
    114114                        }
     
    135135                        switch ( desc.slots[i].vslot )
    136136                        {
    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;
    140140                                default             : break;
    141141                        }
     
    144144                        for ( uint32 i = 0; i < channel->count; i++)
    145145                        {
    146                                 vec3& p = *((vec3*)(raw_data + vtx_size*i + p_offset ));
     146                                vec3& p = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + p_offset );
    147147                                p = vertex_transform * p + vertex_offset;
    148148                        }
     
    151151                        for ( uint32 i = 0; i < channel->count; i++)
    152152                        {
    153                                 vec3& n = *((vec3*)(raw_data + vtx_size*i + n_offset ));
     153                                vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset );
    154154                                n = glm::normalize( normal_transform * n );
    155155                        }
     
    157157                        for ( uint32 i = 0; i < channel->count; i++)
    158158                        {
    159                                 vec4& t = *((vec4*)(raw_data + vtx_size*i + t_offset ));
     159                                vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset );
    160160                                t = vec4( glm::normalize( normal_transform * vec3(t) ), t[3] );
    161161                        }
     
    173173        size_t n_offset = 0;
    174174        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 ) ];
    176176        for ( uint32 i = 0; i < channel->desc.count; ++i )
    177177                if ( channel->desc.slots[i].vslot == slot::NORMAL )
     
    182182        for ( uint32 i = 0; i < channel->count; ++i )
    183183        {
    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 );
    185185                normal = -normal;
    186186        }
     
    211211                                if ( desc.slots[i].etype == FLOAT_VECTOR_3 )
    212212                                {
    213                                         p_offset  = (int)desc.slots[i].offset;
     213                                        p_offset  = int( desc.slots[i].offset );
    214214                                        p_channel = channel;
    215215                                }
     
    217217                        case slot::NORMAL   : if ( desc.slots[i].etype == FLOAT_VECTOR_3 )
    218218                                {
    219                                         n_offset  = (int)desc.slots[i].offset;
     219                                        n_offset  = int( desc.slots[i].offset );
    220220                                        n_channel = m_data->m_channels[ c ];
    221221                                        n_channel_index = c;
     
    224224                        case slot::TEXCOORD : if ( desc.slots[i].etype == FLOAT_VECTOR_2 )
    225225                                {
    226                                         t_offset  = (int)desc.slots[i].offset;
     226                                        t_offset  = int( desc.slots[i].offset );
    227227                                        t_channel = channel;
    228228                                }
     
    246246
    247247        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 );
    249249        vec3* tangents2             = new vec3[ p_channel->count ];
    250250        uint32 tri_count = i_channel ? i_channel->count / 3 : t_channel->count / 3;
     
    259259                if ( i_type == UINT )
    260260                {
    261                         const uint32* idata = (const uint32*)i_channel->data;
     261                        const uint32* idata = reinterpret_cast<const uint32*>( i_channel->data );
    262262                        ti0 = idata[ i * 3 ];
    263263                        ti1 = idata[ i * 3 + 1 ];
     
    266266                else if ( i_type == USHORT )
    267267                {
    268                         const uint16* idata = (const uint16*)i_channel->data;
     268                        const uint16* idata = reinterpret_cast<const uint16*>( i_channel->data );
    269269                        ti0 = idata[ i * 3 ];
    270270                        ti1 = idata[ i * 3 + 1 ];
     
    278278                }
    279279
    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 );
    283283                vec2 st1 = w3 - w1;
    284284                vec2 st2 = w2 - w1;
     
    291291                        uint32 nti1 = t_channel->count * set + ti1;
    292292                        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 );
    296296                        vec3 xyz1 = v3 - v1;
    297297                        vec3 xyz2 = v2 - v1;
     
    317317        for ( unsigned int i = 0; i < vtx_count; ++i )
    318318        {
    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 );
    320320                const vec3 t = vec3(tangents[i]);
    321321                if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) )
     
    420420        int och_ti = other->get_channel_index( slot::TEXCOORD );
    421421        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;
    426426        if ( count % size != 0 || ocount % osize != 0 ) return;
    427427        if ( count / size != ocount / osize ) return;
     
    440440                                {
    441441                                        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 );
    445445
    446446                                }
     
    448448                        case UINT   :
    449449                                {
    450                                         uint32* indexes = (uint32*)m_data->m_channels[c]->data;
     450                                        uint32* indexes = reinterpret_cast<uint32*>( m_data->m_channels[c]->data );
    451451                                        for ( uint32 i = old->count; i < m_data->m_channels[c]->count; ++i )
    452452                                                indexes[i] += size;
  • trunk/src/gfx/skeletal_mesh.cc

    r395 r406  
    1616{
    1717        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 );
    1919        m_bone_offset.resize( bones->get_count() );
    2020        m_transform.resize( bones->get_count() );
     
    3535        if ( a_anim )
    3636        {
    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 ) );
    3939                {
    4040                        size_t skeleton_size = m_bone_offset.size();
     
    5151                                const md5_vtx_pntiw& vert = m_vtx_data[i];
    5252
    53                                 for ( size_t j = 0; j < 4; ++j )
     53                                for ( int j = 0; j < 4; ++j )
    5454                                {
    55                                         unsigned index = (unsigned)vert.boneindex[j];
     55                                        unsigned index = unsigned( vert.boneindex[j] );
    5656                                        float weight   = vert.boneweight[j];
    5757                                        const quat& orient      = m_transform[index].get_orientation();
     
    7171void nv::skeletal_animation_entry_cpu::update_skeleton( transform* skeleton, float time ) const
    7272{
    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() );
    7474        float anim_duration = frame_duration * m_node_data->get_duration();
    7575        float new_time = fmodf( time, anim_duration ) * 0.001f;
     
    152152                if ( bi != bone_names.end() )
    153153                {
    154                         bone_id = (sint16)bi->second;
     154                        bone_id = sint16( bi->second );
    155155                }
    156156                m_bone_ids[n] = bone_id;
     
    207207        if ( m_bone_data && a_anim )
    208208        {
    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 );
    210210                anim->prepare( m_bone_data );
    211211                anim->update_skeleton( m_transform, a_anim_time );
  • trunk/src/gl/gl_context.cc

    r403 r406  
    9191        // TODO: support GL_READ_FRAMEBUFFER?
    9292        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 ) );
    9494        if ( info )
    9595        {
     
    101101                        //              if ( tinfo->size.y == 0 )
    102102                                //                      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 );
    104104                }
    105105                else
    106106                {
    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 );
    108108                }
    109109
     
    116116        // TODO: support GL_READ_FRAMEBUFFER?
    117117        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 ) );
    119119        if ( info )
    120120        {
     
    213213void nv::gl_context::bind( program p )
    214214{
    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 );
    216217        if ( info )
    217218        {
    218219                glUseProgram( info->glid );
    219                 ((gl_device*)m_device)->update_uniforms( info );
     220                gdevice->update_uniforms( info );
    220221        }
    221222}
     
    248249                        }
    249250
    250                         glVertexAttribPointer( 
    251                                 location, 
    252                                 static_cast<GLint>( vba.components ), 
     251                        glVertexAttribPointer(
     252                                location,
     253                                static_cast<GLint>( vba.components ),
    253254                                nv::datatype_to_gl_enum( vba.dtype ),
    254255                                GL_FALSE,
    255256                                static_cast<GLsizei>( vba.stride ),
    256                                 (void*)vba.offset
     257                                reinterpret_cast<void*>( vba.offset )
    257258                                );
    258259                }
     
    317318}
    318319
    319 void nv::gl_context::update( texture t, void* data )
     320void nv::gl_context::update( texture t, const void* data )
    320321{
    321322        const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
     
    327328
    328329                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 );
    330331        }
    331332}
     
    338339                GLenum glenum = buffer_type_to_enum( info->type );
    339340                glBindBuffer( glenum, info->glid );
    340                 glBufferSubData( glenum, (GLintptr)offset, (GLsizeiptr)size, data );
     341                glBufferSubData( glenum, GLintptr( offset ), GLsizeiptr( size ), data );
    341342        }
    342343}
     
    700701void nv::gl_context::apply_engine_uniforms( program p, const scene_state& s )
    701702{
    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 );
    703704        if ( info )
    704705        {
     
    725726                if ( slots[i] > OUTPUT_7 ) buffers[i] = 0;
    726727        }
    727         glDrawBuffers( (GLsizei)count, buffers );
     728        glDrawBuffers( GLsizei( count ), buffers );
    728729}
    729730
  • trunk/src/gl/gl_device.cc

    r403 r406  
    5353        assert( image->format->BytesPerPixel > 2 );
    5454        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 ) );
    5656        return data;
    5757}
     
    6262{
    6363        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" );
    6565        if ( !image )
    6666        {
     
    7171        assert( image->format->BytesPerPixel > 2 );
    7272        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 ) );
    7474        return idata;
    7575}
     
    8686}
    8787
    88 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data /*= nullptr */ )
     88nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
    8989{
    9090        unsigned glid = 0;
     
    106106        }
    107107
    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 );
    114114
    115115        glBindTexture( gl_type, 0 );
     
    163163
    164164        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 ) );
    166166        glBindBuffer( glenum, 0 );
    167167
     
    325325                        switch( ubase->get_type() )
    326326                        {
    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;
    338338                        default : break; // error?
    339339                        }
     
    348348        glGetProgramiv( p->glid, GL_ACTIVE_ATTRIBUTES, &params );
    349349
    350         for ( unsigned i = 0; i < (unsigned)params; ++i )
     350        for ( unsigned i = 0; i < unsigned( params ); ++i )
    351351        {
    352352                int attr_nlen;
     
    377377        glGetProgramiv( p->glid, GL_ACTIVE_UNIFORMS, &params );
    378378
    379         for ( unsigned i = 0; i < size_t(params); ++i )
     379        for ( unsigned i = 0; i < unsigned( params ); ++i )
    380380        {
    381381                int uni_nlen;
     
    412412
    413413        const char* pc = shader_code.data();
    414         int l = (int)shader_code.length();
     414        int l = int( shader_code.length() );
    415415
    416416        glShaderSource( glid, 1, &pc, &l );
     
    428428                if ( compile_ok == 0 )
    429429                {
    430                         NV_LOG_ERROR( "Shader #", glid, " error: ", buffer );
     430                        NV_LOG_ERROR( "Shader #", glid, " error: ", string_view( buffer, size_t( length ) ) );
    431431                }
    432432                else
    433433                {
    434                         NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", buffer );
     434                        NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", string_view( buffer, size_t( length ) ) );
    435435                }
    436436        }
  • trunk/src/gl/gl_window.cc

    r395 r406  
    1515{
    1616#if NV_PLATFORM == NV_WINDOWS
    17                 ::SwapBuffers( (HDC)m_hwnd );
     17                ::SwapBuffers( reinterpret_cast<HDC>( m_hwnd ) );
    1818#else
    1919        NV_ASSERT( false, "Native GL context currently only working on Windows!" );
     
    2626        {
    2727#if NV_PLATFORM == NV_WINDOWS
    28                         dynwglDeleteContext( (HGLRC)m_context->get_native_handle() );
     28                        dynwglDeleteContext( reinterpret_cast<HGLRC>( m_context->get_native_handle() ) );
    2929#endif
    3030        }
     
    4040        m_input = a_input;
    4141
    42         m_handle = (void*)handle;
     42        m_handle = handle;
    4343
    4444        // TODO: error checking
    45         HDC hdc = (HDC)dc;
     45        HDC hdc = reinterpret_cast<HDC>( dc );
    4646
    4747        const int wgl_attrib_list[] =
     
    103103//      m_height  = (uint16)rect.bottom;
    104104        m_handle  = wm->adopt_window( handle );
    105         m_hwnd    = ::GetDC( (HWND)handle );
     105        m_hwnd    = ::GetDC( reinterpret_cast<HWND>( handle ) );
    106106        m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) );
    107107#else
  • trunk/src/gui/gui_ascii_renderer.cc

    r395 r406  
    1818        bool   clear;
    1919        bool   border;
    20         char  border_chars[8];
     20        uchar8 border_chars[8];
    2121        uint32 border_color;
    2222        uint32 text_color;
     
    4242        }
    4343        else
    44                 er = (ascii_render_data*)( e->m_render_data );
     44                er = static_cast< ascii_render_data* >( e->m_render_data );
    4545
    4646        rectangle abs = e->m_absolute;
     
    6868                                er->border_color = uint32( border_color );
    6969                        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] );
    7171                }
    7272        }
     
    7575void ascii_renderer::draw( element* e )
    7676{
    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 );
    7878        rectangle abs = e->m_absolute;
    7979        if ( er->clear ) m_terminal->clear( abs );
     
    8282                for ( int x = 0; x < abs.get_width(); ++x )
    8383                {
    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] );
    8686                }
    8787
    8888                for ( int y = 0; y < abs.get_height(); ++y )
    8989                {
    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] );
    9292                }
    9393
    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] );
    9898        }
    9999        if ( !e->m_text.empty() )
     
    102102                for ( char c : e->m_text )
    103103                {
    104                         m_terminal->print( p, er->text_color, (unsigned char)c );
     104                        m_terminal->print( p, er->text_color, static_cast< unsigned char >( c ) );
    105105                        ++p.x;
    106106                }
  • trunk/src/gui/gui_gfx_renderer.cc

    r395 r406  
    190190{
    191191        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 );
    193193        id_name.append( std::string( buffer, len ) );
    194194        auto i = m_font_names.find( id_name );
     
    197197                return i->second;
    198198        }
    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 ) );
    201201        f->load_glyphs( "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " );
    202202        m_fonts.push_back( f );
     
    228228void gfx_renderer::redraw( element* e, uint32 )
    229229{
    230         screen_render_data* sr = (screen_render_data*)m_render_data;
     230        screen_render_data* sr = reinterpret_cast< screen_render_data* >( m_render_data );
    231231        if ( e->m_render_data == nullptr )
    232232        {
    233233                e->m_render_data = new element_render_data( &sr->buffer );
    234234        }
    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 );
    236236        size_t size_before = er->buffer.data().size();
    237237
     
    318318                        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 ) )
    319319                        {
    320                                 size_t font_id = load_font( path, (uint16)border );
     320                                size_t font_id = load_font( path, size_t( border ) );
    321321                                texture_font* font = get_font( font_id );
    322322                                position p = abs.ul + position( 0, border );
     
    361361void gfx_renderer::draw( element* e )
    362362{
    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 );
    364364        er->buffer.commit();
    365365}
     
    367367void gfx_renderer::draw()
    368368{
    369         screen_render_data* sr = (screen_render_data*)m_render_data;
     369        screen_render_data* sr = reinterpret_cast< screen_render_data* >( m_render_data );
    370370
    371371        if ( m_reupload )
    372372        {
    373                 m_context->update( sr->tex, (void*)m_atlas.get_data() );
     373                m_context->update( sr->tex, m_atlas.get_data() );
    374374                m_reupload = false;
    375375        }
     
    392392        if ( m_render_data )
    393393        {
    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 );
    395395                delete m_render_data;
    396396        }
  • trunk/src/gui/gui_style.cc

    r395 r406  
    3434        if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), cselector, centry, LUA_TTABLE ) ) return false;
    3535        vec = vec4();
    36         for (size_t i = 0; i < 4; ++i )
     36        for ( int i = 0; i < 4; ++i )
    3737        {
    38                 lua_rawgeti( m_lua, -1, static_cast<int>( i+1 ) );
     38                lua_rawgeti( m_lua, -1, i+1 );
    3939                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 ) );
    4141                lua_pop( m_lua, 1 );
    4242        }
  • trunk/src/io/c_stream.cc

    r395 r406  
    3131        if ( m_file )
    3232        {
    33                 ::fclose( (FILE*)m_file );
     33                ::fclose( reinterpret_cast<FILE*>( m_file ) );
    3434        }
    3535}
     
    3838{
    3939        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;
    4141}
    4242
     
    4444{
    4545        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;
    4747}
    4848
    4949bool c_stream::seek( long offset, origin orig )
    5050{
    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 );
    5252}
    5353
    5454nv::size_t c_stream::tell()
    5555{
    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;
    5757}
    5858
     
    7272                        return 0;
    7373                }
    74                 m_file_size = (size_t) (fstat.st_size);                 
     74                m_file_size = static_cast<size_t>(fstat.st_size);               
    7575        }
    7676
     
    8282        if ( m_file != nullptr )
    8383        {
    84                 ::fflush( (FILE*)m_file );
     84                ::fflush( reinterpret_cast<FILE*>( m_file ) );
    8585        }
    8686}
  • trunk/src/io/string_table.cc

    r395 r406  
    2222        uint32 cs_size = s.size() + 1;
    2323        NV_ASSERT( m_offsets.size() < index(-1), "Too many strings!" );
    24         index  result  = (index)m_offsets.size();
     24        index  result = index( m_offsets.size() );
    2525        size_t dsize = m_data.size();
    2626        m_offsets.push_back( dsize );
     
    3737        raw_copy( m_offsets.begin(), m_offsets.end(), offsets );
    3838        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() ) );
    4040}
    4141
    4242void nv::string_table_creator::dump( nv::stream* out ) const
    4343{
    44         index  count = (index)m_offsets.size();
     44        index  count = index( m_offsets.size() );
    4545        uint32 size  = m_data.size();
    4646        out->write( &count,  sizeof( count ), 1 );
  • trunk/src/lib/assimp.cc

    r395 r406  
    3535        assimp_library.open( path );
    3636
    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) );
    3838#       include <nv/lib/detail/assimp_functions.inc>
    3939#       undef NV_ASSIMP_FUN
  • trunk/src/lib/curses.cc

    r395 r406  
    2222        curses_library.open( path );
    2323
    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) );
    2525#       include <nv/lib/detail/curses_functions.inc>
    2626#       undef NV_CURSES_FUN
  • trunk/src/lib/fmod.cc

    r395 r406  
    125125        fmod_library.open( path );
    126126
    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) );
    128128#       include <nv/lib/detail/fmod_functions.inc>
    129129#       undef NV_FMOD_FUN
  • trunk/src/lib/freetype2.cc

    r395 r406  
    2121        freetype_library.open( path );
    2222
    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) );
    2424#       include <nv/lib/detail/freetype2_functions.inc>
    2525#       undef NV_FREETYPE_FUN
  • trunk/src/lib/gl.cc

    r395 r406  
    8282        if ( gl_library_loaded && !force_reload ) return true;
    8383#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 );
    8787#else
    8888        if ( !gl_library.is_open() ) gl_library.open( path );
    8989
    9090#       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) );
    9494#       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) );
    9898#       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) );
    101101#       endif
    102102#endif
     
    114114}
    115115
     116
     117
    116118bool nv::load_wgl_library( const char* path /*= NV_GL_PATH */, bool force_reload )
    117119{
     
    119121#if NV_PLATFORM == NV_WINDOWS
    120122#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 );
    125127#else //
    126128        if ( !gl_library.is_open() ) gl_library.open( path );
    127129
    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) );
    132134#endif
    133135#       define NV_GL_FUN( rtype, fname, fparams ) NV_GL_LOAD( fname )
     
    161163        BOOL  (NV_GL_APIENTRY *wgl_deletecontext) (HGLRC)      = nullptr;
    162164
    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") );
    166168
    167169        WNDCLASS wndClass;
     
    175177        wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    176178        wndClass.hInstance = hInstance;
    177         wndClass.lpfnWndProc = (WNDPROC) DefWindowProc;
     179        wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>( DefWindowProc );
    178180        wndClass.lpszClassName = TEXT("Dummy67789");
    179181        wndClass.lpszMenuName = 0;
     
    253255
    254256#       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) ); \
    256258        count++; if ( !symbol ) fail_count++;
    257259
     
    266268        default : {
    267269                NV_LOG_ERROR( "load_gl_extension - unknown extension \"", name, "\"!" );
    268                 return nullptr;
     270                return false;
    269271        }
    270272        }
     
    274276        {
    275277                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 ) );
    277279                return false;
    278280        }
  • trunk/src/lib/lua.cc

    r395 r406  
    128128static const lua_Number *lua_version_51 (lua_State*)
    129129{
    130         static const lua_Number version = (lua_Number)LUA_VERSION_NUM;
     130        static const lua_Number version = lua_Number( LUA_VERSION_NUM );
    131131        return &version;
    132132}
     
    227227#endif
    228228
    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) );
    230230#       if NV_LUA_VERSION == NV_LUA_52
    231231#               define NV_LUA_FUN_51( rtype, fname, fparams )
     
    246246
    247247#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) );
    250250        bool version_52 = lua_library.try_get("luaL_checkversion_") != nullptr;
    251251        if (version_52)
    252252        {
    253253#       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) ); \
    255255        fn = call_##fn2##_compat;
    256256#       include <nv/lib/detail/lua_functions_compat.inc>
     
    280280        {
    281281#       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) );
    283283#       include <nv/lib/detail/lua_functions_compat.inc>
    284284#       undef NV_LUA_COMPAT_FUN
  • trunk/src/lib/sdl.cc

    r395 r406  
    2020        if ( sdl_library.is_open() ) return true;
    2121        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) );
    2323#       include <nv/lib/detail/sdl_functions.inc>
    2424#       undef NV_SDL_FUN
  • trunk/src/lib/sdl_image.cc

    r395 r406  
    2121        sdl_image_library.open( path );
    2222
    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) );
    2424#       include <nv/lib/detail/sdl_image_functions.inc>
    2525#       undef NV_SDL_FUN
  • trunk/src/lib/sdl_mixer.cc

    r395 r406  
    2121        sdl_mixer_library.open( path );
    2222
    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) );
    2424#       include <nv/lib/detail/sdl_mixer_functions.inc>
    2525#       undef NV_SDL_FUN
  • trunk/src/lua/lua_function.cc

    r395 r406  
    55// For conditions of distribution and use, see copying.txt file in root folder.
    66
    7 #include <nv/lua/lua_function.hh>
     7#include "nv/lua/lua_function.hh"
    88
    9 #include <nv/lua/lua_raw.hh>
     9#include "nv/core/logging.hh"
     10#include "nv/lua/lua_raw.hh"
    1011
    1112using namespace nv;
     13
     14#define NV_LUA_ABORT( func, ... ) \
     15        NV_LOG_CRITICAL( "lua::" func " : ", __VA_ARGS__ ) \
     16        NV_ABORT( "lua::" func " : critical error!" )
    1217
    1318lua::function_base::function_base( lua_State* a_L, const path& a_path, bool a_global /*= true*/ ) : L(a_L)
     
    1621        {
    1722                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() );
    1924        }
    2025
     
    2227        {
    2328                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() );
    2530        }
    2631        m_ref = luaL_ref( L, LUA_REGISTRYINDEX );
     
    6166                std::string error = lua_tostring( L, -1 );
    6267                lua_pop( L, 1 );
    63                 throw std::runtime_error(error.c_str());
     68                NV_LUA_ABORT( "function_base::call", "call failed - ", error.c_str() );
    6469        }
    6570}
  • trunk/src/lua/lua_glm.cc

    r397 r406  
    1111#include "nv/stl/type_traits/common.hh"
    1212
    13 static size_t nlua_swizzel_lookup[256];
     13static int nlua_swizzel_lookup[256];
    1414
    1515using nv::lua::detail::is_vec;
     
    1818using nv::lua::detail::push_vec;
    1919
    20 inline bool nlua_is_swizzel( const unsigned char* str, size_t max )
     20inline bool nlua_is_swizzel( const unsigned char* str, int max )
    2121{
    2222        while (*str)
     
    155155{
    156156        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 ) );
    158158        else
    159159                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 )) );
    161161                else
    162162                        push_vec<T>( L, to_vec<T>( L, 1 ) + to_vec<T>( L, 2 ) );
     
    168168{
    169169        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 ) );
    171171        else
    172172                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 )) );
    174174                else
    175175                        push_vec<T>( L, to_vec<T>( L, 1 ) - to_vec<T>( L, 2 ) );
     
    181181{
    182182        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 ) );
    184184        else
    185185                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 )) );
    187187                else
    188188                        push_vec<T>( L, to_vec<T>( L, 1 ) * to_vec<T>( L, 2 ) );
     
    194194{
    195195        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 ) );
    197197        else
    198198                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 )) );
    200200                else
    201201                        push_vec<T>( L, to_vec<T>( L, 1 ) / to_vec<T>( L, 2 ) );
     
    226226        T* v = to_pvec<T>( L, 1 );
    227227        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;
    231231
    232232        if ( len == 1 )
     
    264264        T* v = to_pvec<T>( L, 1 );
    265265        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;
    269269        if( len == 1 )
    270270        {
     
    272272                if ( idx < vlen )
    273273                {
    274                         (*v)[idx] = (typename T::value_type)luaL_checknumber( L, 3 );
     274                        (*v)[idx] = static_cast<typename T::value_type>( luaL_checknumber( L, 3 ) );
    275275                        return 0;
    276276                }
     
    279279        {
    280280                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;
    284284                default: break;
    285285                }
  • trunk/src/lua/lua_handle.cc

    r395 r406  
    1616        NV_LUA_STACK_ASSERT( L, +1 );
    1717        lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
    18         lua_rawgeti( L, -1, (int)index );                 // table, entry
     18        lua_rawgeti( L, -1, int( index ) );                 // table, entry
    1919        if ( !lua_istable( L, -1 ) )
    2020        {
     
    5858        lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex );
    5959        lua_insert( L, -2 );
    60         lua_rawseti( L, -2, (int)index );
     60        lua_rawseti( L, -2, int( index ) );
    6161        lua_pop( L, 1 );
    6262}
     
    6767        lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
    6868        lua_pushinteger( L, 0 );
    69         lua_rawseti( L, -2, (int)index );
     69        lua_rawseti( L, -2, int( index ) );
    7070        lua_pop( L, 1 );
    7171}
  • trunk/src/lua/lua_map_area.cc

    r395 r406  
    6767        else
    6868        {
    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 ) );
    7070        }
    7171        return o;
     
    8888void nv::lua::detail::push_map_area( lua_State* L, nv::map_area* c )
    8989{
    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*) ) );
    9191        *pm = c;
    9292        luaL_getmetatable( L, NLUA_MAP_AREA_METATABLE );
     
    237237        lua_rawgeti( L, LUA_REGISTRYINDEX, object_index.get() );
    238238        lua_pushliteral( L, "__map_area_ptr" );
    239         lua_pushlightuserdata( L, (map_area*)area );
     239        lua_pushlightuserdata( L, area );
    240240        lua_rawset( L, -3 );
    241241        lua_pop( L, 1 );
  • trunk/src/lua/lua_map_tile.cc

    r395 r406  
    4040static map_tile* nlua_to_pmap_tile( lua_State* L, int index )
    4141{
    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 ) );
    4343}
    4444
    4545static void nlua_push_map_tile( lua_State* L, const map_tile& tile )
    4646{
    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) ) );
    4848        *result = tile;
    4949        luaL_setmetatable( L, NLUA_MAP_TILE_METATABLE );
     
    6565        map_tile tile;
    6666
    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' ) );
    6969        if ( tile.size_x == 0 )
    7070        {
    71                 tile.size_x = (nv::uint16)code.length();
     71                tile.size_x = nv::uint16( code.length() );
    7272        }
    7373        tile.data  = new nv::uint8[ tile.size_x * tile.size_y ];
     
    8585                        if ( lua_isstring( L, -2 ) && lua_objlen( L, -2 ) == 1 )
    8686                        {
    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 ) ) );
    8888                        }
    8989                        // removes 'value'; keeps 'key' for next iteration */
     
    9595                for ( nv::uint16 row = 0; row < tile.size_y; row++ )
    9696                {
    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 ] );
    9898                        // TODO: check for errors
    9999                        tile.data[ row * tile.size_x + line ] = translation[ gylph ];
     
    108108{
    109109        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 ) ) );
    111111        new_tile->size_x = old_tile->size_x;
    112112        new_tile->size_y = old_tile->size_y;
     
    246246        nv::uint16 org_x = tile->size_x;
    247247        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 ) );
    250250
    251251        nv::uint8* data = new nv::uint8[ new_x * new_y ];
     
    274274static int nlua_map_tile_raw_get( lua_State* L )
    275275{
    276         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     276        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    277277        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    278278        {
     
    289289static int nlua_map_tile_raw_set( lua_State* L )
    290290{
    291         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     291        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    292292        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    293293        {
    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 ) );
    295295        }
    296296        else
    297297        {
    298298                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 ) );
    300300        }
    301301        return 0;
     
    304304static int nlua_map_tile_ascii_get( lua_State* L )
    305305{
    306         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     306        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    307307        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    308308        {
     
    319319static int nlua_map_tile_ascii_set( lua_State* L )
    320320{
    321         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     321        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    322322        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    323323        {
    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 ) );
    325325        }
    326326        else
    327327        {
    328328                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 ) );
    330330        }
    331331        return 0;
     
    334334static int nlua_map_tile_gc( lua_State* L )
    335335{
    336         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     336        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    337337        if ( tile != nullptr )
    338338        {
  • trunk/src/lua/lua_raw.cc

    r395 r406  
    271271                while ( lua_next( L, index ) != 0 )
    272272                {
    273                         result.push_back( (nv::uint8) lua_tointeger( L, -1 ) );
     273                        result.push_back( static_cast<nv::uint8>( lua_tointeger( L, -1 ) ) );
    274274                        lua_pop( L, 1 );
    275275                }
  • trunk/src/lua/lua_state.cc

    r403 r406  
    258258{
    259259        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;
    261261        lua_pop( m_state, 1 );
    262262        return result;
  • trunk/src/rogue/fov_recursive_shadowcasting.cc

    r398 r406  
    2525                position max_radius = m_size-m_position;
    2626                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;
    2828        }
    2929        m_radius2 = m_radius * m_radius;
  • trunk/src/sdl/sdl_audio.cc

    r399 r406  
    3636        if ( info )
    3737        {
    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);
    3939                if ( channel == -1 )
    4040                {
     
    4343                else
    4444                {
    45                         Mix_Volume( channel, int( volume * 128.0f ) );
     45                        Mix_Volume( channel, static_cast<int>( volume * 128.0f ) );
    4646                        if ( pan != 0.0f)
    4747                        {
    48                                 uint8 right = (uint8)( (pan + 1.0f) * 127.0f );
     48                                uint8 right = static_cast<uint8>( (pan + 1.0f) * 127.0f );
    4949                                Mix_SetPanning( channel, 254-right, right );
    5050                        }
     
    6363        if ( info )
    6464        {
    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);
    6666                if ( channel == -1 )
    6767                {
     
    123123        if ( info )
    124124        {
    125                 Mix_FreeChunk( (Mix_Chunk*)info->sdl_sound );
     125                Mix_FreeChunk( static_cast<Mix_Chunk*>( info->sdl_sound ) );
    126126                m_sounds.destroy( a_sound );
    127127        }
  • trunk/src/sdl/sdl_input.cc

    r395 r406  
    2525        kevent.key.code    = KEY_NONE;
    2626
    27         uint32 ucode = (uint32)ke.keysym.sym;
     27        uint32 ucode = static_cast<uint32>( ke.keysym.sym );
    2828
    2929        // if result is a typable char place it into the structure
     
    3636                        int capslock = !!(ke.keysym.mod & KMOD_CAPS);
    3737                        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 ) ) );
    3939                        }
    4040                }
  • trunk/src/sdl/sdl_window.cc

    r395 r406  
    6464
    6565        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 ) ) );
    7070        SDL_GL_SetSwapInterval(1);
    7171
  • trunk/src/stl/assert.cc

    r403 r406  
    6464        exit( 1 );
    6565}
     66
     67
     68NV_NORETURN void nv::exit( int ret_val )
     69{
     70        ::exit( ret_val );
     71}
Note: See TracChangeset for help on using the changeset viewer.