Ticket #1624: galleryopengl2.diff

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

setting value before using is smarter.

  • 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)));
    85 
    8683    // --------------------------------------------------------------------
    8784
    8885    // remove all dirs from m_itemList;
     
    179176    }
    180177}
    181178
     179int GLSingleView::NearestGLTextureSize(int v)
     180{
     181    int n = 0, last = 0;
     182    int s;
     183
     184    for (int s = 0; s < 32; ++s)
     185    {
     186        if (((v >> s) & 1) == 1)
     187        {
     188            ++n;
     189            last = s;
     190        }
     191    }
     192
     193    if (n > 1)
     194        s = 1 << (last + 1);
     195    else
     196        s = 1 << last;
     197
     198    if (s > m_maxTexDim)
     199        s = m_maxTexDim;
     200
     201    return s;
     202}
     203
     204
    182205GLSingleView::~GLSingleView()
    183206{
    184207    if (m_sequence)
     
    220243    // Enable perspective vision
    221244    glClearDepth(1.0f);
    222245
     246    GLint param;
     247    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &param);
     248    m_maxTexDim = param;
     249
     250    m_w = NearestGLTextureSize(screenwidth);
     251    m_h = NearestGLTextureSize(screenheight);
     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();