Ignore:
Timestamp:
Sep 14, 2013, 7:42:46 PM (6 years ago)
Author:
benlitz
Message:

gpu: removed attribute name, everything works using semantic only now. For glsl, semantic is determined from the attribute name which must follow this pattern: in_[Semantic][index], index being optional. Note: this may break most of the projects although I tried to updated every shader accordingly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh.cpp

    r2879 r2922  
    6262
    6363//-----------------------------------------------------------------------------
    64 void GpuShaderData::AddAttribute(const lol::String &new_attribute, VertexUsage usage, int index)
    65 {
    66     m_shader_attrib.Push(new_attribute, m_shader->GetAttribLocation(new_attribute.C(), usage, index));
     64void GpuShaderData::AddAttribute(VertexUsage usage, int index)
     65{
     66    m_shader_attrib.Push(m_shader->GetAttribLocation(usage, index));
    6767}
    6868
     
    7777
    7878//-----------------------------------------------------------------------------
    79 ShaderAttrib const *GpuShaderData::GetAttribute(const lol::String &attribute)
     79ShaderAttrib const *GpuShaderData::GetAttribute(VertexUsage usage, int index)
    8080{
    8181    for (int i = 0; i < m_shader_attrib.Count(); ++i)
    82         if (m_shader_attrib[i].m1 == attribute)
    83             return &m_shader_attrib[i].m2;
     82        if (m_shader_attrib[i].GetUsage() == usage && m_shader_attrib[i].GetIndex() == index)
     83            return &m_shader_attrib[i];
    8484    return nullptr;
    8585}
     
    199199           VertexUsage::GetNameList(vflags).C());
    200200
    201     if (has_position)   gpudata->AddAttribute(gpudata->GetInVertexName(),   VertexUsage::Position, 0);
    202     if (has_normal)     gpudata->AddAttribute(gpudata->GetInNormalName(),   VertexUsage::Normal, 0);
    203     if (has_color)      gpudata->AddAttribute(gpudata->GetInColorName(),    VertexUsage::Color, 0);
    204     if (has_texcoord)   gpudata->AddAttribute(gpudata->GetInTexCoordName(), VertexUsage::TexCoord, 0);
     201    if (has_position)   gpudata->AddAttribute(VertexUsage::Position, 0);
     202    if (has_normal)     gpudata->AddAttribute(VertexUsage::Normal, 0);
     203    if (has_color)      gpudata->AddAttribute(VertexUsage::Color, 0);
     204    if (has_texcoord)   gpudata->AddAttribute(VertexUsage::TexCoord, 0);
    205205
    206206    SetupVertexData(gpudata->m_vert_decl_flags, src_mesh);
     
    409409    ShaderAttrib Attribs[4] = { lol::ShaderAttrib(), lol::ShaderAttrib(), lol::ShaderAttrib(), lol::ShaderAttrib() };
    410410
    411     if (has_position)   Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInVertexName());
    412     if (has_normal)     Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInNormalName());
    413     if (has_color)      Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInColorName());
    414     if (has_texcoord)   Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInTexCoordName());
     411    if (has_position)   Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::Position, 0);
     412    if (has_normal)     Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::Normal, 0);
     413    if (has_color)      Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::Color, 0);
     414    if (has_texcoord)   Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::TexCoord, 0);
    415415
    416416    vdecl->SetStream(vbo, Attribs[0], Attribs[1], Attribs[2], Attribs[3]);
Note: See TracChangeset for help on using the changeset viewer.