Changeset 492 for trunk/src


Ignore:
Timestamp:
05/05/16 19:37:28 (9 years ago)
Author:
epyon
Message:
 
Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gl/gl_context.cc

    r491 r492  
    7474        }
    7575
    76         for ( uint32 i = 0; i < info->count; ++i )
    77         {
    78                 glDisableVertexAttribArray( static_cast<uint32>( info->attr[i].location ) );
    79         }
     76//      for ( uint32 i = 0; i < info->count; ++i )
     77//      {
     78//              glDisableVertexAttribArray( static_cast<uint32>( info->attr[i].location ) );
     79//      }
    8080
    8181
     
    8383}
    8484
    85 nv::framebuffer nv::gl_context::create_framebuffer()
     85nv::framebuffer nv::gl_context::create_framebuffer( uint32 temp_samples )
    8686{
    8787        unsigned glid   = 0;
     
    9292        info->depth_rb_glid = 0;
    9393        info->color_attachment_count = 0;
     94        info->sample_count = temp_samples;
    9495        return result;
    9596}
     
    192193                glGenRenderbuffers( 1, &(info->depth_rb_glid) );
    193194                glBindRenderbuffer( GL_RENDERBUFFER, info->depth_rb_glid );
    194                 glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.x, size.y );
     195                if ( info->sample_count > 1 )
     196                        glRenderbufferStorageMultisample( GL_RENDERBUFFER, info->sample_count, GL_DEPTH_COMPONENT16, size.x, size.y );
     197                else
     198                        glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.x, size.y );
    195199                glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, info->depth_rb_glid );
    196200                glBindRenderbuffer( GL_RENDERBUFFER, 0 );
     
    211215
    212216
     217void nv::gl_context::blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 )
     218{
     219        gl_framebuffer_info* finfo = m_framebuffers.get( from );
     220        gl_framebuffer_info* tinfo = m_framebuffers.get( to );
     221        if ( finfo )
     222        {
     223                glBindFramebuffer( GL_READ_FRAMEBUFFER, finfo->glid );
     224                glBindFramebuffer( GL_DRAW_FRAMEBUFFER, tinfo ? tinfo->glid : 0 );
     225                unsigned filter = mask == clear_state::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST;
     226                int remove_below;
     227                filter = GL_NEAREST;
     228                glBlitFramebuffer( src1.x, src1.y, src2.x, src2.y, dst1.x, dst1.y, dst2.x, dst2.y, clear_state_buffers_to_mask( mask ), filter );
     229                glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
     230                if ( tinfo ) glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
     231        }
     232}
     233
    213234bool nv::gl_context::check( framebuffer_slot ft )
    214235{
     
    220241        switch ( result )
    221242        {
     243        case GL_FRAMEBUFFER_UNDEFINED                     : NV_LOG_ERROR( "gl_context::check : Framebuffer undefined!" ); break;
     244        case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE        : NV_LOG_ERROR( "gl_context::check : Incomplete multisample!" ); break;
     245        case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS      : NV_LOG_ERROR( "gl_context::check : Incomplete layer targets!" ); break;
    222246        case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT         : NV_LOG_ERROR( "gl_context::check : Framebuffer incomplete attachment!" ); break;
    223247        case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : NV_LOG_ERROR( "gl_context::check : Framebuffer missing attachment!" ); break;
     
    255279        {
    256280                NV_ASSERT_ALWAYS( binfo->type == TEXTURE_BUFFER && tinfo->type == TEXTURE_1D_BUFFER, "bad texture or buffer type!" );
    257                 glActiveTexture( GL_TEXTURE0 );
    258                 glBindTexture( GL_TEXTURE_BUFFER, tinfo->glid );
     281                bind( t, TEXTURE_0 );
    259282                glTexBuffer( GL_TEXTURE_BUFFER, image_format_to_internal_enum( tinfo->format.format ), binfo->glid );
    260                 glBindTexture( GL_TEXTURE_BUFFER, 0 );
    261283        }
    262284}
     
    276298void gl_context::bind( texture t, texture_slot slot )
    277299{
    278         const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
    279         if ( info )
    280         {
    281                 glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) );
    282                 glBindTexture( texture_type_to_enum( info->type ), info->glid );
     300        if ( m_bound_textures[ slot ] != t )
     301        {
     302                const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
     303                if ( info )
     304                {
     305                        set_active_texture( slot );
     306                        glBindTexture( texture_type_to_enum( info->type ), info->glid );
     307                }
    283308        }
    284309}
     
    318343}
    319344
     345void nv::gl_context::set_active_texture( texture_slot slot )
     346{
     347        if ( slot != m_active_slot )
     348                glActiveTexture( GL_TEXTURE0 + static_cast<GLenum>( slot ) );
     349}
     350
    320351// void nv::gl_context::unbind( buffer b )
    321352// {
     
    352383        const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
    353384        NV_ASSERT_ALWAYS( info->type != TEXTURE_1D_BUFFER, "Buffer texture passed to update!" );
     385        NV_ASSERT_ALWAYS( info->type != TEXTURE_2D_MULTISAMPLE, "Multisample texture passed to update!" );
    354386        if ( info )
    355387        {
     
    358390                unsigned     gl_type = texture_type_to_enum( info->type );
    359391
    360                 glBindTexture( gl_type, info->glid );
     392                if ( m_bound_textures[ m_active_slot ] != t )
     393                        glBindTexture( gl_type, info->glid );
    361394                int this_should_be_subTexImage;
    362395                if ( info->type == TEXTURE_3D || info->type == TEXTURE_2D_ARRAY )
     
    543576                glDepthMask( mask );
    544577                m_render_state.depth_mask = mask;
     578        }
     579}
     580
     581void gl_context::apply_multisample( bool multisample )
     582{
     583        if ( m_render_state.multisample != multisample )
     584        {
     585                glDepthMask( multisample );
     586                m_render_state.multisample = multisample;
    545587        }
    546588}
     
    727769        apply_color_mask( state.color_mask );
    728770        apply_depth_mask( state.depth_mask );
     771        apply_multisample( state.multisample );
    729772        apply_polygon_mode( state.polygon_mode );
    730773}
     
    736779        // TODO: configurable:
    737780//      load_gl_extensions( GL_EXT_FRAMEBUFFER_BLIT | GL_EXT_FRAMEBUFFER_OBJECT | GL_EXT_TEXTURE_ARRAY );
     781        m_active_slot = texture_slot( -1 );
    738782        force_apply_render_state( m_render_state );
    739783}
  • trunk/src/gl/gl_device.cc

    r491 r492  
    9898        unsigned glid = 0;
    9999        unsigned gl_type = texture_type_to_enum( type );
    100         GLint gl_internal = GLint( nv::image_format_to_internal_enum( aformat.format ) );
     100        GLenum gl_internal = GLenum( nv::image_format_to_internal_enum( aformat.format ) );
    101101        unsigned gl_enum = nv::image_format_to_enum( aformat.format );
    102102
     
    119119        }
    120120
    121         glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) );
    122         glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) );
     121        if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE )
     122        {
     123                glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) );
     124                glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) );
     125        }
    123126       
    124         if ( gl_enum != GL_RED_INTEGER )
     127        if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE && gl_enum != GL_RED_INTEGER )
    125128        {
    126129                glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) );
     
    130133        if ( is_depth )
    131134        {
    132                 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    133                 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
     135//              glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
     136//              glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    134137
    135138                // This is to allow usage of shadow2DProj function in the shader
     
    146149//      glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso );
    147150
    148         glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum(aformat.type), data );
     151        if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE )
     152                glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum(aformat.type), data );
     153        else
     154                glTexImage2DMultisample( gl_type, 4, gl_internal, size.x, size.y, 1 );
    149155
    150156        glBindTexture( gl_type, 0 );
     
    163169nv::texture nv::gl_device::create_texture( texture_type type, pixel_format format )
    164170{
    165         NV_ASSERT_ALWAYS( type == TEXTURE_1D_BUFFER );
     171        NV_ASSERT_ALWAYS( type == TEXTURE_1D_BUFFER, "create_texture not texture buffer!" );
    166172        unsigned glid = 0;
    167         unsigned gl_type = texture_type_to_enum( type );
    168173
    169174        glGenTextures( 1, &glid );
     
    552557                NV_ASSERT( u, "Unknown uniform type!" );
    553558                (*p->m_uniform_map)[ name ] = u;
     559                //NV_LOG_DEBUG( "Uniform : ", name, " - ", utype, "/", uni_len );
     560
    554561        }
    555562
  • trunk/src/gl/gl_enum.cc

    r491 r492  
    1515        switch( type )
    1616        {
    17         case TEXTURE_1D       : return GL_TEXTURE_1D;
    18         case TEXTURE_2D       : return GL_TEXTURE_2D;
    19         case TEXTURE_RECT     : return GL_TEXTURE_RECTANGLE;
    20         case TEXTURE_3D       : return GL_TEXTURE_3D;
    21         case TEXTURE_CUBE     : return GL_TEXTURE_CUBE_MAP;
    22         case TEXTURE_1D_ARRAY : return GL_TEXTURE_1D_ARRAY;
    23         case TEXTURE_2D_ARRAY : return GL_TEXTURE_2D_ARRAY;
    24         case TEXTURE_1D_BUFFER: return GL_TEXTURE_BUFFER;
     17        case TEXTURE_1D             : return GL_TEXTURE_1D;
     18        case TEXTURE_2D             : return GL_TEXTURE_2D;
     19        case TEXTURE_RECT           : return GL_TEXTURE_RECTANGLE;
     20        case TEXTURE_3D             : return GL_TEXTURE_3D;
     21        case TEXTURE_CUBE           : return GL_TEXTURE_CUBE_MAP;
     22        case TEXTURE_1D_ARRAY       : return GL_TEXTURE_1D_ARRAY;
     23        case TEXTURE_2D_ARRAY       : return GL_TEXTURE_2D_ARRAY;
     24        case TEXTURE_1D_BUFFER      : return GL_TEXTURE_BUFFER;
     25        case TEXTURE_2D_MULTISAMPLE : return GL_TEXTURE_2D_MULTISAMPLE;
    2526        NV_RETURN_COVERED_DEFAULT( 0 );
    2627        }
  • trunk/src/gui/gui_environment.cc

    r444 r492  
    182182                {
    183183                        handle h = get_element( position( ev.mbutton.x, ev.mbutton.y ) );
     184                        element* e = m_elements.get( h );
     185                        if ( e->m_on_click ) e->m_on_click();
     186
    184187                        set_selected( h );
    185188                        return true;
     
    312315}
    313316
     317void nv::gui::environment::set_on_click( handle e, const function< void() >& on_click )
     318{
     319        element* ep = m_elements.get( e );
     320        if ( ep != nullptr )
     321        {
     322                ep->m_on_click = on_click;
     323        }
     324}
     325
    314326void nv::gui::environment::set_text( handle e, const string_twine& text )
    315327{
  • trunk/src/gui/gui_gfx_renderer.cc

    r491 r492  
    249249                const char* stext[] = { "", "selected", "hover" };
    250250                const char* selector = stext[border];
    251                 if ( e->m_flags[HOVER] )    selector = stext[2];
    252                 if ( e->m_flags[SELECTED] ) selector = stext[1];
     251                if ( e->m_flags[HOVER] && e->m_flags[DIRTY_HOVER] )    selector = stext[2];
     252                if ( e->m_flags[SELECTED] && e->m_flags[DIRTY_SELECT] ) selector = stext[1];
    253253
    254254                if ( m_style.get( e, "skin", selector, path ) )
  • trunk/src/lib/gl.cc

    r491 r492  
    2626#define NV_GL_FUN_REN( rtype, fname, rname, fparams ) rtype (NV_GL_APIENTRY *rname) fparams = nullptr;
    2727#define NV_GL_FUN_EXT NV_GL_FUN
    28 #include <nv/lib/detail/gl_core/gl_functions_3_1.inc>
     28#include <nv/lib/detail/gl_core/gl_functions_3_2.inc>
    2929#if NV_PLATFORM == NV_WINDOWS
    3030#include <nv/lib/detail/wgl_functions.inc>
     
    106106#       define NV_GL_FUN( rtype, fname, fparams ) NV_GL_LOAD( fname )
    107107#       define NV_GL_FUN_EXT( rtype, fname, fparams ) NV_GL_LOAD_EXT( fname )
    108 #       include <nv/lib/detail/gl_core/gl_functions_3_1.inc>
     108#       include <nv/lib/detail/gl_core/gl_functions_3_2.inc>
    109109#       undef NV_GL_FUN_EXT
    110110#       undef NV_GL_FUN
  • trunk/src/sdl/sdl_window.cc

    r491 r492  
    3030        //      SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 );
    3131
    32         SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    33         SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
     32        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
     33        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
    3434
    3535        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
Note: See TracChangeset for help on using the changeset viewer.