add fill rect

This commit is contained in:
NishiOwO 2025-04-12 15:27:22 +09:00
parent 3f09d91eb5
commit 6dd7152746
No known key found for this signature in database
GPG Key ID: 27EF69B208EB9343
2 changed files with 20 additions and 0 deletions

View File

@ -65,6 +65,22 @@ void gf_graphic_draw_texture_2d(gf_draw_t* draw, float x, float y, float w, floa
gf_graphic_end_2d(draw);
}
void gf_graphic_fill_rect(gf_draw_t* draw, float x, float y, float w, float h, float r, float g, float b, float a) {
gf_graphic_begin_2d(draw);
gf_draw_driver_set_color(draw, r, g, b, a);
glBegin(GL_QUADS);
glVertex2f(x, y);
glVertex2f(x, y + h);
glVertex2f(x + w, y + h);
glVertex2f(x + w, y);
glEnd();
gf_graphic_end_2d(draw);
}
void gf_graphic_text(gf_draw_t* draw, float x, float y, float size, const char* text, float r, float g, float b, float a) {
int i;
for(i = 0; text[i] != 0; i++) {

View File

@ -13,9 +13,13 @@
#include <gf_type/texture.h>
GF_EXPORT void gf_graphic_clear(gf_draw_t* draw);
GF_EXPORT void gf_graphic_begin_2d(gf_draw_t* draw);
GF_EXPORT void gf_graphic_end_2d(gf_draw_t* draw);
GF_EXPORT void gf_graphic_draw_texture_2d(gf_draw_t* draw, float x, float y, float w, float h, gf_texture_t* texture, float r, float g, float b, float a);
GF_EXPORT void gf_graphic_fill_rect(gf_draw_t* draw, float x, float y, float w, float h, float r, float g, float b, float a);
GF_EXPORT void gf_graphic_text(gf_draw_t* draw, float x, float y, float size, const char* text, float r, float g, float b, float a);
#endif