/** * @brief Bind and draw a texture * @param[in] texnum The texture id (already uploaded of course) * @param[in] x normalized x value on the screen * @param[in] y normalized y value on the screen * @param[in] w normalized width value * @param[in] h normalized height value */ void R_DrawTexture (int texnum, int x, int y, int w, int h) { const vec2_t vertexes[] = {{x, y}, {x + w, y}, {x + w, y + h}, {x, y + h}}; R_BindTexture(texnum); R_DrawImageArray(default_texcoords, vertexes, NULL); }
static void UI_RadarNodeDrawArrays (const vec4_t color, vec2_t coords[4], vec2_t vertices[4], const image_t* image) { R_Color(color); R_DrawImageArray((const vec2_t*)coords, (const vec2_t*)vertices, image); R_Color(nullptr); }
/** * @brief Draw a normalized (to the screen) image * @param[in] flip Flip the icon rendering (horizontal) * @param[in] x,y The coordinates (normalized) * @param[in] w The width (normalized) * @param[in] h The height (normalized) * @param[in] sh The s part of the texture coordinate (horizontal) * @param[in] th The t part of the texture coordinate (horizontal) * @param[in] sl The s part of the texture coordinate (vertical) * @param[in] tl The t part of the texture coordinate (vertical) * @param[in] image The image to draw */ void UI_DrawNormImage (bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const image_t* image) { float nw, nh, x1, x2, x3, x4, y1, y2, y3, y4; if (!image) return; /* normalize to the screen resolution */ x1 = x * viddef.rx; y1 = y * viddef.ry; /* provided width and height (if any) take precedence */ if (w) nw = w * viddef.rx; else nw = 0; if (h) nh = h * viddef.ry; else nh = 0; /* horizontal texture mapping */ if (sh) { if (!w) nw = (sh - sl) * viddef.rx; sh /= image->width; } else { if (!w) nw = ((float)image->width - sl) * viddef.rx; sh = 1.0f; } sl /= image->width; /* vertical texture mapping */ if (th) { if (!h) nh = (th - tl) * viddef.ry; th /= image->height; } else { if (!h) nh = ((float)image->height - tl) * viddef.ry; th = 1.0f; } tl /= image->height; /* fill the rest of the coordinates to make a rectangle */ x4 = x1; x3 = x2 = x1 + nw; y2 = y1; y4 = y3 = y1 + nh; if (flip) { const float tmp = sl; sl = sh; sh = tmp; } const vec2_t imageTexcoords[4] = {{sl, tl}, {sh, tl}, {sh, th}, {sl, th}}; const vec2_t imageVerts[4] = {{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}; R_DrawImageArray(imageTexcoords, imageVerts, image); }