Changeset 739f15f in git


Ignore:
Timestamp:
17/05/13 14:23:09 (6 years ago)
Author:
Olly Betts <olly@…>
Branches:
add-show-splays
Parents:
f481ceb
Message:

Use OpenGL alpha to draw faded splay legs

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/gfxcore.cc

    rf481ceb r739f15f  
    161161    m_PointGrid = new list<LabelInfo*>[HITTEST_SIZE * HITTEST_SIZE];
    162162
    163     m_HalfPens = new GLAPen[NUM_COLOUR_BANDS + 1];
    164     m_FullPens = new GLAPen[NUM_COLOUR_BANDS + 1];
     163    m_Pens = new GLAPen[NUM_COLOUR_BANDS + 1];
    165164    for (int pen = 0; pen < NUM_COLOUR_BANDS + 1; ++pen) {
    166         m_HalfPens[pen].SetColour(REDS[pen] / 255.0 / 4.0,
    167                               GREENS[pen] / 255.0 / 4.0,
    168                               BLUES[pen] / 255.0 / 4.0);
    169         m_FullPens[pen].SetColour(REDS[pen] / 255.0,
     165        m_Pens[pen].SetColour(REDS[pen] / 255.0,
    170166                              GREENS[pen] / 255.0,
    171167                              BLUES[pen] / 255.0);
    172168    }
    173     m_Pens = m_FullPens;
    174169}
    175170
     
    178173    TryToFreeArrays();
    179174
    180     delete[] m_HalfPens;
    181     delete[] m_FullPens;
     175    delete[] m_Pens;
    182176    delete[] m_PointGrid;
    183177}
     
    20162010    list<traverse>::const_iterator tend = m_Parent->traverses_end();
    20172011
    2018     /* We draw the faded splays first, so that they are behind
    2019        the centerline in case of any conflicts */
    20202012    if (m_Splays == SPLAYS_SHOW_FADED) {
    2021         SwitchToHalfPens();
     2013        SetAlpha(0.25);
    20222014        while (trav != tend) {
    20232015            if ((*trav).isSplay)
     
    20252017            ++trav;
    20262018        }
    2027         SwitchToFullPens();
     2019        SetAlpha(1.0);
    20282020        trav = m_Parent->traverses_begin();
    20292021    }
  • src/gfxcore.h

    rf481ceb r739f15f  
    189189    long drawtime;
    190190
    191     GLAPen * m_HalfPens;
    192     GLAPen * m_FullPens;
    193 
    194191    GLAPen * m_Pens;
    195192
     
    277274    void DrawShadowedBoundingBox();
    278275    void DrawBoundingBox();
    279 
    280     void SwitchToFullPens() {
    281         m_Pens = m_FullPens;
    282     }
    283 
    284     void SwitchToHalfPens() {
    285         m_Pens = m_HalfPens;
    286     }
    287276
    288277public:
  • src/gla-gl.cc

    rf481ceb r739f15f  
    296296    m_AntiAlias = false;
    297297    list_flags = 0;
     298    alpha = 1.0;
    298299}
    299300
     
    805806    }
    806807
     808    glEnable(GL_BLEND);
     809    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    807810    if (m_AntiAlias) {
    808811        glEnable(GL_LINE_SMOOTH);
    809         glEnable(GL_BLEND);
    810         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    811812    } else {
    812813        glDisable(GL_LINE_SMOOTH);
     
    922923{
    923924    // Set the colour for subsequent operations.
    924     glColor3f(pen.GetRed() * rgb_scale, pen.GetGreen() * rgb_scale,
    925               pen.GetBlue() * rgb_scale);
     925    glColor4f(pen.GetRed() * rgb_scale, pen.GetGreen() * rgb_scale,
     926              pen.GetBlue() * rgb_scale, alpha);
    926927}
    927928
     
    929930{
    930931    // Set the colour for subsequent operations.
    931     glColor3dv(pen.components);
     932    glColor4d(pen.components[0], pen.components[1], pen.components[2], alpha);
    932933}
    933934
  • src/gla.h

    rf481ceb r739f15f  
    124124    GLuint m_CrossTexture;
    125125
     126    Double alpha;
     127
    126128    bool m_SmoothShading;
    127129    bool m_Textured;
     
    180182    void SetColour(const GLAPen& pen);
    181183    void SetColour(gla_colour colour);
     184    void SetAlpha(double new_alpha) { alpha = new_alpha; }
    182185
    183186    void DrawText(glaCoord x, glaCoord y, glaCoord z, const wxString& str);
Note: See TracChangeset for help on using the changeset viewer.