コード例 #1
0
ファイル: matrix.cpp プロジェクト: jlirochon/client
void set_matrix_item(float *matrix, int width, int height, int scale) {
    float xoffset = 1 - (scale * 64) / width * 2;
    float yoffset = 1 - (scale * 64) / height * 2;

    set_matrix_item_r(matrix, width, height, scale * 64, xoffset, yoffset,
                      -PI/4, -PI/10, 0);
}
コード例 #2
0
ファイル: inventory.c プロジェクト: gitter-badger/client-1
// Render a cube with ID w at x, y. This function is used to render the inventory
// blocks, like the belt and the inventory screen.
void render_inventory_block(Attrib *attrib, int w, float s, float x, float y, int flag) {
    glUseProgram(attrib->program);
    glUniform3f(attrib->camera, 0, 0, 5);
    glUniform1i(attrib->sampler, 0); // GL_TEXTURE0
    glUniform1f(attrib->timer, PI*2);
    float identity[16];
    mat_identity(identity);
    glUniformMatrix4fv(attrib->extra5, 1, GL_FALSE, identity);
    float matrix[16];
    GLuint buffer;

    // Default block rotations
    float rx = -PI/4;
    float ry = -PI/10;
    float rz = 0;
    float dz = 0;

    switch (flag) {
        case 1:
            rx = -PI/8;
            break;
        case 2:
            rx = -PI/8;
            ry = -PI/10;
            rz = -PI/16;
            dz = -1.0;
            break;
        case 3:
            rx = -PI/8;
            ry = -PI/10;
            rz = -PI/16;
            dz = 2.0;
            break;
    }

    set_matrix_item_r(matrix, g->width, g->height, s, x, y, rx, ry, rz);

    if (is_plant(w)) {
        glDeleteBuffers(1, &buffer);
        buffer = gen_plant_buffer(0, 0, dz, 0.5, w);
    } else {
        buffer = gen_cube_buffer(0, 0, dz, 0.5, w);
    }
    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);
    if (is_plant(w)) {
        draw_plant(attrib, buffer);
    } else {
        draw_cube(attrib, buffer);
    }
    del_buffer(buffer);
}