/** * @brief Draw the current texture on a quad the size of the renderbuffer */ static inline void R_DrawQuad (void) { /** @todo use default_texcoords */ const vec2_t texcoord[] = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } }; const vec2_t verts[] = { { 0.0f, 0.0f }, Vector2FromInt(fbo_render->width, 0.0f), Vector2FromInt(fbo_render->width, fbo_render->height), Vector2FromInt(0.0f, fbo_render->height) }; glVertexPointer(2, GL_FLOAT, 0, verts); R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texcoord); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); refdef.batchCount++; R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY); R_BindDefaultArray(GL_VERTEX_ARRAY); }
/** * @param[in] flip Flip the icon rendering (horizontal) * @param[in] sprite Context sprite * @param[in] status The state of the sprite node * @param[in] posX,posY Absolute X/Y position of the top-left corner * @param[in] sizeX,sizeY Width/height of the bounding box */ void UI_DrawSpriteInBox (bool flip, const uiSprite_t* sprite, uiSpriteStatus_t status, int posX, int posY, int sizeX, int sizeY) { float texX; float texY; const char* image; /** @todo Add warning */ if (status >= SPRITE_STATUS_MAX) return; /** @todo merge all this cases */ if (sprite->single || sprite->blend) { texX = sprite->pos[SPRITE_STATUS_NORMAL][0]; texY = sprite->pos[SPRITE_STATUS_NORMAL][1]; image = sprite->image[SPRITE_STATUS_NORMAL]; } else if (sprite->pack64) { texX = sprite->pos[SPRITE_STATUS_NORMAL][0]; texY = sprite->pos[SPRITE_STATUS_NORMAL][1] + (64 * status); image = sprite->image[SPRITE_STATUS_NORMAL]; } else { texX = sprite->pos[status][0]; texY = sprite->pos[status][1]; image = sprite->image[status]; if (!image) { if (texX == 0 && texY == 0) { texX = sprite->pos[SPRITE_STATUS_NORMAL][0]; texY = sprite->pos[SPRITE_STATUS_NORMAL][1]; image = sprite->image[SPRITE_STATUS_NORMAL]; } else { image = sprite->image[SPRITE_STATUS_NORMAL]; } } } if (!image) return; if (sprite->blend) { const vec_t* color = sprite->color[status]; R_Color(color); } if (sprite->tiled_17_1_3) { const vec2_t pos = Vector2FromInt(posX, posY); const vec2_t size = Vector2FromInt(sizeX, sizeY); UI_DrawPanel(pos, size, image, texX, texY, tile_template_17_1_3); } else if (sprite->tiled_25_1_3) { const vec2_t pos = Vector2FromInt(posX, posY); const vec2_t size = Vector2FromInt(sizeX, sizeY); UI_DrawPanel(pos, size, image, texX, texY, tile_template_25_1_3); } else if (sprite->tiled_popup) { const vec2_t pos = Vector2FromInt(posX, posY); const vec2_t size = Vector2FromInt(sizeX, sizeY); UI_DrawPanel(pos, size, image, texX, texY, tile_template_popup); } else if (sprite->border != 0) { const vec2_t pos = Vector2FromInt(posX, posY); const vec2_t size = Vector2FromInt(sizeX, sizeY); UI_DrawBorderedPanel(pos, size, image, texX, texY, sprite->size[0], sprite->size[1], sprite->border); } else { posX += (sizeX - sprite->size[0]) / 2; posY += (sizeY - sprite->size[1]) / 2; UI_DrawNormImageByName(flip, posX, posY, sprite->size[0], sprite->size[1], texX + sprite->size[0], texY + sprite->size[1], texX, texY, image); } if (sprite->blend) R_Color(nullptr); }