mirror of
https://github.com/nishiowo/nishbox
synced 2025-04-21 04:04:39 +00:00
fix texture handling
This commit is contained in:
parent
01bfee71fc
commit
5d4f90ff4e
@ -77,10 +77,25 @@ void gf_draw_reshape(gf_draw_t* draw) { gf_draw_driver_reshape(draw); }
|
||||
/* Runs every frame */
|
||||
void gf_draw_frame(gf_draw_t* draw) {
|
||||
gf_color_t color;
|
||||
float z = 16;
|
||||
color.r = color.g = color.b = color.a = 255;
|
||||
if(draw->draw_3d) {
|
||||
}
|
||||
gf_graphic_draw_texture_polygon(draw, test_texture, color, 3, 4, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, -1.0);
|
||||
gf_graphic_draw_texture_polygon(draw, test_texture, color, GF_GRAPHIC_3D, 4,
|
||||
/* clang-format off */
|
||||
0.0, 0.0,
|
||||
-1.0, 0.0, -1.0,
|
||||
|
||||
0.0, 1.0 * z,
|
||||
-1.0, 0.0, 1.0,
|
||||
|
||||
1.0 * z, 1.0 * z,
|
||||
1.0, 0.0, 1.0,
|
||||
|
||||
1.0 * z, 0.0,
|
||||
1.0, 0.0, -1.0
|
||||
/* clang-format on */
|
||||
);
|
||||
if(draw->draw != NULL) draw->draw(draw);
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,4 @@ void gf_graphic_text(gf_draw_t* draw, float x, float y, float size, const char*
|
||||
|
||||
float gf_graphic_text_width(gf_draw_t* draw, float size, const char* text) { return (float)strlen(text) * (size * GF_GRAPHIC_FONT_ASPECT_X / GF_GRAPHIC_FONT_ASPECT_Y); }
|
||||
|
||||
void gf_graphic_draw_texture_2d(gf_draw_t* draw, float x, float y, float w, float h, gf_texture_t* texture, gf_color_t color) { gf_graphic_draw_texture_polygon(draw, texture, color, 2, 4, 0.0, 0.0, x, y, 0.0, 1.0, x, y + h, 1.0, 1.0, x + w, y + h, 1.0, 0.0, x + w, y); }
|
||||
void gf_graphic_draw_texture_2d(gf_draw_t* draw, float x, float y, float w, float h, gf_texture_t* texture, gf_color_t color) { gf_graphic_draw_texture_polygon(draw, texture, color, GF_GRAPHIC_2D, 4, 0.0, 0.0, x, y, 0.0, 1.0, x, y + h, 1.0, 1.0, x + w, y + h, 1.0, 0.0, x + w, y); }
|
||||
|
@ -55,8 +55,10 @@ gf_draw_driver_texture_t* gf_draw_driver_register_texture(gf_draw_t* draw, int w
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, d);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
#if 0
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
#endif
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
return r;
|
||||
|
@ -23,6 +23,9 @@
|
||||
#define GF_GRAPHIC_FONT_ASPECT_X 1
|
||||
#define GF_GRAPHIC_FONT_ASPECT_Y 2
|
||||
|
||||
#define GF_GRAPHIC_2D 2
|
||||
#define GF_GRAPHIC_3D 3
|
||||
|
||||
#define GF_SET_COLOR(color, red, green, blue, alpha) \
|
||||
color.r = (red); \
|
||||
color.g = (green); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user