Пример #1
0
static inline void _render_world(game *g) {
    glClear(GL_COLOR_BUFFER_BIT);

    glUseProgram(g->world_shader);

    glUniformMatrix4fv(g->d.matrix_id, 1, GL_FALSE, &g->d.mvp[0][0]);
    glUniform4fv(g->d.colors_id, 5, GET_COL(COLORS_OFFSET));
    glUniform1ui(g->d.inv_state_id, !g->w->state);

    glBindBuffer(GL_ARRAY_BUFFER, g->d.vert_buffer);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);

    glBindTexture(GL_TEXTURE_BUFFER, g->d.data_tex);
    glActiveTexture(GL_TEXTURE0 + g->d.tex_id);
    glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, g->d.data_buffer);
    glUniform1i(g->d.tex_buff_id, g->d.tex_id);

    glDrawArrays(GL_TRIANGLES, 0, g->d.vcount / 2);

    glDisableVertexAttribArray(0);
    glBindTexture(GL_TEXTURE_BUFFER, 0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    glUseProgram(0);
}
Пример #2
0
int 
AlarmInfoStmtStep(AlarmDBHandle *handle, AlarmInfoStmt *_stmt, AlarmInfo *info)
{
    int dcode;
    sqlite3_stmt *stmt = (sqlite3_stmt *) _stmt;

    dcode = AlarmStmtStep(handle, _stmt);
    if (1 != dcode) {
        return dcode;
    }

    GET_COL(stmt, 0, info->store);
    info->guid = sqlite3_column_int64(stmt, 1);
    info->time = BongoCalTimeNewFromUint64(sqlite3_column_int64(stmt, 2), FALSE, NULL);
    GET_COL(stmt, 3, info->summary);
    GET_COL(stmt, 4, info->email);
    GET_COL(stmt, 5, info->sms);

    return 1;
}
Пример #3
0
static void _update_colors(game *g, int color_scheme) {
    if (color_scheme >= COLOR_SCHEME_COUNT) {
        g->color_scheme = 0;
    } else if (color_scheme < 0) {
        g->color_scheme = COLOR_SCHEME_COUNT-1;
    } else {
        g->color_scheme = color_scheme;
    }

    glClearColor(
            COLOR_SCHEMES[g->color_scheme][BG_OFFSET],
            COLOR_SCHEMES[g->color_scheme][BG_OFFSET + 1],
            COLOR_SCHEMES[g->color_scheme][BG_OFFSET + 2],
            COLOR_SCHEMES[g->color_scheme][BG_OFFSET + 3]);

    g->o.bg_col = _map_surface_colors(g->o.bg->format, GET_COL(OVERLAY_OFFSET));
    g->o.font_col = _map_sdl_colors(GET_COL(FONT_OFFSET));

    _overlay_static_text(g);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, g->o.bg->w, g->o.bg->h, g->o.tex_format, g->o.tex_type, g->o.bg->pixels);
}
Пример #4
0
static void _overlay_static_text(game *g) {
    overlay *o = &g->o;
    char *temp_text = calloc(o->label_text_max, sizeof(char));

    // Overlay background has a border
    SDL_FillRect(o->bg, NULL, _map_surface_colors(o->bg->format, GET_COL(BORDER_OFFSET)));
    SDL_Rect bg_rect = {1, 1, o->bg->w-2, o->bg->h-2};
    SDL_FillRect(o->bg, &bg_rect, o->bg_col);

    SDL_FillRect(o->font_surf, NULL, o->bg_col);

    int line = 0;

    // Draw world map size
    snprintf(temp_text, o->label_text_max, "World %ux%u", g->w->xlim, g->w->ylim);
    _overlay_draw_text(o, temp_text, 1, line++, NULL);

    // Draw world data size
    snprintf(temp_text, o->label_text_max, "World data size: %lu", g->w->data_size * sizeof(world_store));
    _overlay_draw_text(o, temp_text, 1, line++, NULL);

    line = 5;
    // Draw FPS label
    snprintf(temp_text, o->label_text_max, "Avg. FPS: ");
    _overlay_draw_text(o, temp_text, 0, line++, &o->avg_fps_loc);

    snprintf(temp_text, o->label_text_max, "FPS: ");
    _overlay_draw_text(o, temp_text, 0, line++, &o->fps_loc);

    // Draw generation label
    snprintf(temp_text, o->label_text_max, "Generation: ");
    _overlay_draw_text(o, temp_text, 0, line++, &o->gen_loc);

    // Draw state label
    snprintf(temp_text, o->label_text_max, "State: ");
    _overlay_draw_text(o, temp_text, 0, line++, &o->state_loc);

    // Draw sub state label
    snprintf(temp_text, o->label_text_max, "Step: ");
    _overlay_draw_text(o, temp_text, 0, line++, &o->step_loc);
}