Changeset 406 for trunk/src/gl


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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.