Esempio n. 1
0
void gen_tex_coords(block_t *block, GLuint texture) {
    // TODO: do less work when called from glDrawElements?

    block->tex[texture] = (GLfloat *)malloc(block->len * 2 * sizeof(GLfloat));
    texgen_state_t *texgen = &state.texgen[texture];
    if (state.enable.texgen_s[texture]) {
        if (texgen->S == texgen->T) {
            tex_coord_loop(block, block->tex[texture], texgen->S, texgen->Sv, texgen->Tv);
        } else {
            tex_coord_loop(block, block->tex[texture], texgen->S, texgen->Sv, NULL);
        }
    }
    if (state.enable.texgen_t[texture]) {
        tex_coord_loop(block, block->tex[texture] + 1, texgen->T, texgen->Tv, NULL);
    }
}
Esempio n. 2
0
void gen_tex_coords(GLfloat *verts, GLfloat **coords, GLint count) {
    // TODO: do less work when called from glDrawElements?

    *coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
    if (state.enable.texgen_s)
        tex_coord_loop(verts, *coords, count, state.texgen.S, state.texgen.Sv);
    if (state.enable.texgen_t)
        tex_coord_loop(verts, *coords+1, count, state.texgen.T, state.texgen.Tv);

    int i;
    for (i = 0; i < count; i++) {
        GLfloat *tex = &(*coords)[i];
        if (state.enable.texgen_s)
            tex[0] = gen_tex_coord(&verts[i], state.texgen.S, state.texgen.Sv);

        if (state.enable.texgen_t)
            tex[1] = gen_tex_coord(&verts[i], state.texgen.T, state.texgen.Tv);
    }
}