Ejemplo n.º 1
0
int up(TIFF *T, int i)
{
    if (i < 6)
        return TIFFSetDirectory(T, i);
    else
    {
        if (up(T, face_parent(i)))
            return dn(T, face_index(i));
        else
            return 0;
    }
}
Ejemplo n.º 2
0
void sph_model::draw_face(const int *fv, int fc,
                          const int *pv, int pc,
                          double r, double l, double t, double b, int d, int i)
{
    GLuint o = 0;
    int then = time;

    if (status[i] != s_halt)
    {
        for (int fi = 0; fi < fc; ++fi)
        {
            int e = fi * 8 + d;
            
            glActiveTexture(GL_TEXTURE0 + e);

            o = cache.get_page(fv[fi], i, time, then);

            glUniform1f(alpha[e], age(then));
            glBindTexture(GL_TEXTURE_2D, o);
        }
        glUniform2f(tex_a[d], GLfloat(r), GLfloat(t));
        glUniform2f(tex_d[d], GLfloat(l), GLfloat(b));
    }

    if (status[i] == s_pass)
    {
        for (int pi = 0; pi < pc; ++pi)
            cache.get_page(pv[pi], i, time, then);
    }
    
    if (status[i] == s_pass)
    {
        const double x = (r + l) * 0.5;
        const double y = (t + b) * 0.5;

        draw_face(fv, fc, pv, pc, r, x, t, y, d + 1, face_child(i, 0));
        draw_face(fv, fc, pv, pc, x, l, t, y, d + 1, face_child(i, 1));
        draw_face(fv, fc, pv, pc, r, x, y, b, d + 1, face_child(i, 2));
        draw_face(fv, fc, pv, pc, x, l, y, b, d + 1, face_child(i, 3));
    }

    if (status[i] == s_draw)
    {
        int n, s, e, w, j = 0;
        
        face_neighbors(i, n, s, e, w);
        
        if (i > 5) j = (status[face_parent(n)] == s_draw ? 1 : 0)
                     | (status[face_parent(s)] == s_draw ? 2 : 0)
                     | (status[face_parent(e)] == s_draw ? 4 : 0)
                     | (status[face_parent(w)] == s_draw ? 8 : 0);

        glUniform1i(level, d);
        
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elements[j]);
        glDrawElements(GL_QUADS, count, GL_UNSIGNED_SHORT, 0);
    }
    
    if (status[i] != s_halt)
    {
        for (int fi = 0; fi < fc; ++fi)
        {
            glActiveTexture(GL_TEXTURE0 + fi * 8 + d);
            glBindTexture(GL_TEXTURE_2D, cache.get_fill());
        }
    }
}