Ignore:
Timestamp:
08/28/15 18:28:34 (10 years ago)
Author:
epyon
Message:
  • 3D/2D_ARRAY texture support
File:
1 edited

Legend:

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

    r462 r463  
    111111}
    112112
    113 void nv::gl_context::attach( framebuffer f, texture depth )
     113void nv::gl_context::attach( framebuffer f, texture depth, int layer /*= -1*/ )
    114114{
    115115        // TODO: framebuffer variable, so no re-binding?
     
    121121                glBindFramebuffer( GL_FRAMEBUFFER, info->glid );
    122122                unsigned gl_type = texture_type_to_enum( tinfo->type );
    123                 if ( tinfo )
    124                 {
    125                         glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, gl_type, tinfo->glid, 0 );
     123                unsigned glid = ( tinfo ? tinfo->glid : 0 );
     124                if ( layer >= 0 )
     125                {
     126                        glFramebufferTextureLayer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tinfo->glid, 0, layer );
    126127                }
    127128                else
    128129                {
    129                         glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, gl_type, 0, 0 );
    130                 }
    131         }
     130                        glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, gl_type, glid, 0 );
     131                }
     132        }
     133
    132134}
    133135
     
    328330        {
    329331                image_format format  = info->format;
    330                 ivec2        size    = info->size;
     332                ivec3        size    = info->size;
    331333                unsigned     gl_type = texture_type_to_enum( info->type );
    332334
    333335                glBindTexture( gl_type, info->glid );
    334                 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 );
     336                if ( info->type == TEXTURE_3D || info->type == TEXTURE_2D_ARRAY )
     337                        glTexImage3D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum( format.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data );
     338                else
     339                        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 );
    335340        }
    336341}
     
    690695{
    691696        // TODO: configurable:
    692         load_gl_extensions( GL_EXT_FRAMEBUFFER_BLIT | GL_EXT_FRAMEBUFFER_OBJECT );
     697        load_gl_extensions( GL_EXT_FRAMEBUFFER_BLIT | GL_EXT_FRAMEBUFFER_OBJECT | GL_EXT_TEXTURE_ARRAY );
    693698        force_apply_render_state( m_render_state );
    694699
Note: See TracChangeset for help on using the changeset viewer.