Ticket #1624: galleryopengl.diff

File galleryopengl.diff, 1.9 KB (added by ivor@…, 20 years ago)

texture size patch

  • glsingleview.cpp

     
    8080    gContext->GetScreenSettings(xbase, screenwidth, wmult,
    8181                                ybase, screenheight, hmult);
    8282
    83     m_w = min(1024, 1 << (int)ceil(log((float)screenwidth)/log((float)2)));
    84     m_h = min(1024, 1 << (int)ceil(log((float)screenheight)/log((float)2)));
     83    m_w = NearestGLTextureSize(screenwidth);
     84    m_h = NearestGLTextureSize(screenheight);
    8585
    8686    // --------------------------------------------------------------------
    8787
     
    179179    }
    180180}
    181181
     182int GLSingleView::NearestGLTextureSize(int v)
     183{
     184    int n = 0, last = 0;
     185    int s;
     186
     187    for (int s = 0; s < 32; ++s)
     188    {
     189        if (((v >> s) & 1) == 1)
     190        {
     191            ++n;
     192            last = s;
     193        }
     194    }
     195
     196    if (n > 1)
     197        s = 1 << (last + 1);
     198    else
     199        s = 1 << last;
     200
     201    if (s > m_maxTexDim)
     202        s = m_maxTexDim;
     203
     204    return s;
     205}
     206
     207
    182208GLSingleView::~GLSingleView()
    183209{
    184210    if (m_sequence)
     
    220246    // Enable perspective vision
    221247    glClearDepth(1.0f);
    222248
     249    GLint param;
     250    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &param);
     251    m_maxTexDim = param;
     252
    223253    loadImage();
    224254}
    225255
  • glsingleview.h

     
    102102
    103103    GLuint        m_texInfo;
    104104    bool          m_showInfo;
    105    
     105    int           m_maxTexDim;   
     106
    106107    int           m_i;
    107108    int           m_dir;
    108109    float         m_points[40][40][3];
     
    114115    SequenceBase               *m_sequence;
    115116
    116117private:
    117    
     118
     119    int NearestGLTextureSize(int);   
    118120    void  advanceFrame();
    119121    void  retreatFrame();
    120122    void  loadImage();