/* * @brief Draw all 2D geometry accumulated for the current frame. */ void R_Draw2D(void) { R_DrawFills(); R_DrawLines(); R_DrawChars(); }
/** * @brief Fills a box of pixels with a single color */ void R_DrawFill (int x, int y, int w, int h, const vec4_t color) { const float nx = x * viddef.rx; const float ny = y * viddef.ry; const float nw = w * viddef.rx; const float nh = h * viddef.ry; const int r = color[0] * 255.0; const int g = color[1] * 255.0; const int b = color[2] * 255.0; const int a = color[3] * 255.0; const uint32_t c = LittleLong((r << 0) + (g << 8) + (b << 16) + (a << 24)); if (r_fill_arrays.color_index >= lengthof(r_fill_arrays.colors)) return; /* duplicate color data to all 4 verts */ memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 0], &c, 4); memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 4], &c, 4); memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 8], &c, 4); memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 12], &c, 4); r_fill_arrays.color_index += 16; /* populate verts */ r_fill_arrays.verts[r_fill_arrays.vert_index + 0] = nx; r_fill_arrays.verts[r_fill_arrays.vert_index + 1] = ny; r_fill_arrays.verts[r_fill_arrays.vert_index + 2] = nx + nw; r_fill_arrays.verts[r_fill_arrays.vert_index + 3] = ny; r_fill_arrays.verts[r_fill_arrays.vert_index + 4] = nx + nw; r_fill_arrays.verts[r_fill_arrays.vert_index + 5] = ny + nh; r_fill_arrays.verts[r_fill_arrays.vert_index + 6] = nx; r_fill_arrays.verts[r_fill_arrays.vert_index + 7] = ny + nh; r_fill_arrays.vert_index += 8; /** @todo this shouldn't be here, but only called once at the end of the frame * but this is needed here because a) we don't want them to get rendered on top of the console * and b) the ui stuff relies on the order of these renderings */ R_DrawFills(); }