Ejemplo n.º 1
0
void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
    if (mode == GL_QUAD_STRIP)
        mode = GL_TRIANGLE_STRIP;

    displaylist_t *active = state.list.active;
    if (active) {
        block_t *block = block_from_arrays(mode, first, count);
        bl_end(block);
        dl_append_block(active, block);
        return;
    }

    if (should_intercept_render(mode)) {
        block_t *block = block_from_arrays(mode, first, count);
        bl_end(block);
        bl_draw(block);
        bl_free(block);
    } else {
        LOAD_GLES(glDrawArrays);
        gles_glDrawArrays(mode, first, count);
    }
}
Ejemplo n.º 2
0
Archivo: gl.c Proyecto: rzr/glshim
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *uindices) {
    // TODO: split for count > 65535?
    GLushort *indices = copy_gl_array(uindices, type, 1, 0, GL_UNSIGNED_SHORT, 1, 0, count);
    // TODO: do this in a more direct fashion.
    if (should_intercept_render(mode)) {
        glBegin(mode);
        for (int i = 0; i < count; i++) {
            glArrayElement(indices[i]);
        }
        glEnd();
        free(indices);
        return;
    }

    bool compiling = (state.list.active && state.list.compiling);
    if (compiling) {
        renderlist_t *list = NULL;
        GLsizei min, max;

        if (compiling)
            list = state.list.active = extend_renderlist(state.list.active);

        normalize_indices(indices, &max, &min, count);
        list = arrays_to_renderlist(list, mode, 0, max + 1);
        list->indices = indices;
        list->len = count;

        end_renderlist(list);
        if (! compiling) {
            draw_renderlist(list);
            free_renderlist(list);
        }
    } else {
        LOAD_GLES(glDrawElements);
        gles_glDrawElements(mode, count, type, indices);
        free(indices);
    }
}
Ejemplo n.º 3
0
Archivo: gl.c Proyecto: rzr/glshim
void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
    if (mode == GL_QUAD_STRIP)
        mode = GL_TRIANGLE_STRIP;

    renderlist_t *list, *active = state.list.active;
    if (active && state.list.compiling) {
        list = state.list.active = extend_renderlist(active);
        arrays_to_renderlist(list, mode, first, count);
        return;
    }

    if (should_intercept_render(mode)) {
        list = arrays_to_renderlist(NULL, mode, first, count);
        end_renderlist(list);
        draw_renderlist(list);
        free_renderlist(list);
    } else {
        // TODO: some draw states require us to use the full pipeline here
        // like texgen, stipple, npot
        LOAD_GLES(glDrawArrays);
        gles_glDrawArrays(mode, first, count);
    }
}
Ejemplo n.º 4
0
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *uindices) {
    // TODO: split for count > 65535?
    GLushort *indices = gl_copy_array(uindices, type, 1, 0, GL_UNSIGNED_SHORT, 1, 0, count, false);
    // TODO: do this in a more direct fashion.
    if (should_intercept_render(mode)) {
        glBegin(mode);
        state.block.active->artificial = true;
        for (int i = 0; i < count; i++) {
            glArrayElement(indices[i]);
        }
        glEnd();
        free(indices);
        return;
    }

    displaylist_t *list = state.list.active;
    if (list) {
        GLsizei min, max;

        normalize_indices(indices, &max, &min, count);
        block_t *block = block_from_arrays(mode, min, max + 1);
        block->indices = indices;
        block->count = count;

        bl_end(block);
        if (list) {
            dl_append_block(list, block);
        } else {
            bl_draw(block);
            bl_free(block);
        }
    } else {
        LOAD_GLES(glDrawElements);
        gles_glDrawElements(mode, count, type, indices);
        free(indices);
    }
}