Ignore:
Timestamp:
08/07/14 10:29:34 (11 years ago)
Author:
epyon
Message:
  • removed gl_names - too much bloat for too little gain
File:
1 edited

Legend:

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

    r299 r300  
    8888        : vertex_shader( GL_VERTEX_SHADER ), fragment_shader( GL_FRAGMENT_SHADER )
    8989{
     90        glid = glCreateProgram();
    9091        compile( vertex_program, fragment_program );
    9192}
     
    9394gl_program::~gl_program()
    9495{
    95         if ( is_valid() )
     96        if ( glid != 0 )
    9697        {
    9798                // Detach the shaders from the program
    98                 glDetachShader( m_name.get_value(), vertex_shader.get_id() );
    99                 glDetachShader( m_name.get_value(), fragment_shader.get_id() );
     99                glDetachShader( glid, vertex_shader.get_id() );
     100                glDetachShader( glid, fragment_shader.get_id() );
     101                glDeleteProgram( glid );
    100102        }
    101103}
     
    106108        if (!fragment_shader.compile( fragment_program )) { return false; }
    107109
    108         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::POSITION   ), "nv_position"  );
    109         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TEXCOORD   ), "nv_texcoord"  );
    110         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::NORMAL     ), "nv_normal"    );
    111         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::COLOR      ), "nv_color"     );
    112         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TANGENT    ), "nv_tangent"   );
    113         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::BONEINDEX  ), "nv_boneindex" );
    114         glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::BONEWEIGHT ), "nv_boneweight");
    115 
    116         glAttachShader( m_name.get_value(), fragment_shader.get_id() );
    117         glAttachShader( m_name.get_value(), vertex_shader.get_id() );
    118         glLinkProgram( m_name.get_value() );
     110        glBindAttribLocation( glid, static_cast<GLuint>( slot::POSITION   ), "nv_position"  );
     111        glBindAttribLocation( glid, static_cast<GLuint>( slot::TEXCOORD   ), "nv_texcoord"  );
     112        glBindAttribLocation( glid, static_cast<GLuint>( slot::NORMAL     ), "nv_normal"    );
     113        glBindAttribLocation( glid, static_cast<GLuint>( slot::COLOR      ), "nv_color"     );
     114        glBindAttribLocation( glid, static_cast<GLuint>( slot::TANGENT    ), "nv_tangent"   );
     115        glBindAttribLocation( glid, static_cast<GLuint>( slot::BONEINDEX  ), "nv_boneindex" );
     116        glBindAttribLocation( glid, static_cast<GLuint>( slot::BONEWEIGHT ), "nv_boneweight");
     117
     118        glAttachShader( glid, fragment_shader.get_id() );
     119        glAttachShader( glid, vertex_shader.get_id() );
     120        glLinkProgram( glid );
    119121
    120122        if (!validate())
     
    129131bool gl_program::is_valid() const
    130132{
    131         return m_name.is_valid();
     133        return glid != 0;
    132134}
    133135
     
    135137{
    136138        int params;
    137         glGetProgramiv( m_name.get_value(), GL_ACTIVE_ATTRIBUTES, &params );
     139        glGetProgramiv( glid, GL_ACTIVE_ATTRIBUTES, &params );
    138140
    139141        for ( unsigned i = 0; i < (unsigned)params; ++i )
     
    144146                char name_buffer[128];
    145147
    146                 glGetActiveAttrib( m_name.get_value(), i, 128, &attr_nlen, &attr_len, &attr_type, name_buffer );
     148                glGetActiveAttrib( glid, i, 128, &attr_nlen, &attr_len, &attr_type, name_buffer );
    147149
    148150                string name( name_buffer, size_t(attr_nlen) );
     
    151153                if ( name.substr(0,3) == "gl_" ) continue;
    152154
    153                 int attr_loc = glGetAttribLocation( m_name.get_value(), name.c_str() );
     155                int attr_loc = glGetAttribLocation( glid, name.c_str() );
    154156
    155157                m_attribute_map[ name ] = new attribute( name, attr_loc, gl_enum_to_datatype( attr_type ), attr_len );
     
    160162{
    161163        int params;
    162         glGetProgramiv( m_name.get_value(), GL_ACTIVE_UNIFORMS, &params );
     164        glGetProgramiv( glid, GL_ACTIVE_UNIFORMS, &params );
    163165
    164166        for ( unsigned i = 0; i < size_t(params); ++i )
     
    169171                char name_buffer[128];
    170172
    171                 glGetActiveUniform( m_name.get_value(), i, 128, &uni_nlen, &uni_len, &uni_type, name_buffer );
     173                glGetActiveUniform( glid, i, 128, &uni_nlen, &uni_len, &uni_type, name_buffer );
    172174
    173175                string name( name_buffer, size_t(uni_nlen) );
     
    176178                if ( name.substr(0,3) == "gl_" ) continue;
    177179
    178                 int uni_loc = glGetUniformLocation( m_name.get_value(), name.c_str() );
     180                int uni_loc = glGetUniformLocation( glid, name.c_str() );
    179181                datatype utype = gl_enum_to_datatype( uni_type );
    180182               
     
    232234        int status;
    233235
    234         glGetProgramiv( m_name.get_value(), GL_LINK_STATUS, &status );
    235         glGetProgramInfoLog( m_name.get_value(), buffer_size, &length, buffer );
    236 
    237         NV_LOG( LOG_INFO, "Program #" << m_name.get_value() << (status == GL_FALSE ? " failed to compile!" : " compiled successfully.") );
     236        glGetProgramiv( glid, GL_LINK_STATUS, &status );
     237        glGetProgramInfoLog( glid, buffer_size, &length, buffer );
     238
     239        NV_LOG( LOG_INFO, "Program #" << glid << (status == GL_FALSE ? " failed to compile!" : " compiled successfully.") );
    238240
    239241        if ( length > 0 )
    240242        {
    241                 NV_LOG( LOG_INFO, "Program #" << m_name.get_value() << " log: " << buffer );
     243                NV_LOG( LOG_INFO, "Program #" << glid << " log: " << buffer );
    242244        }
    243245
     
    247249        }
    248250
    249         glValidateProgram( m_name.get_value() );
    250         glGetProgramiv( m_name.get_value(), GL_VALIDATE_STATUS, &status );
     251        glValidateProgram( glid );
     252        glGetProgramiv( glid, GL_VALIDATE_STATUS, &status );
    251253
    252254        if ( status == GL_FALSE )
    253255        {
    254                 glGetProgramInfoLog( m_name.get_value(), buffer_size, &length, buffer );
    255                 NV_LOG( LOG_ERROR, "Program #" << m_name.get_value() << " validation error : " << buffer );
     256                glGetProgramInfoLog( glid, buffer_size, &length, buffer );
     257                NV_LOG( LOG_ERROR, "Program #" << glid << " validation error : " << buffer );
    256258                return false;
    257259        }
Note: See TracChangeset for help on using the changeset viewer.