From 0243be4eebe488b449742474d4301a39f00ac67f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 14 Apr 2025 23:13:50 +0200 Subject: Add scaling option for texture, allow nearest neighbour scaling --- include/mgl/gl_macro.h | 1 + include/mgl/graphics/texture.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mgl/gl_macro.h b/include/mgl/gl_macro.h index 07ce1c4..574a3d8 100644 --- a/include/mgl/gl_macro.h +++ b/include/mgl/gl_macro.h @@ -48,6 +48,7 @@ #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #define GL_CLAMP_TO_EDGE 0x812F +#define GL_NEAREST 0x2600 #define GL_LINEAR 0x2601 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 diff --git a/include/mgl/graphics/texture.h b/include/mgl/graphics/texture.h index d65adee..b658daf 100644 --- a/include/mgl/graphics/texture.h +++ b/include/mgl/graphics/texture.h @@ -14,6 +14,12 @@ typedef enum { MGL_TEXTURE_FORMAT_RGBA } mgl_texture_format; +typedef enum { + MGL_TEXTURE_SCALE_NEAREST, + MGL_TEXTURE_SCALE_LINEAR, + MGL_TEXTURE_SCALE_LINEAR_MIPMAP /* generate mipmaps (available since opengl 3.0) */ +} mgl_texture_scale_type; + struct mgl_texture { unsigned int id; int width; @@ -22,18 +28,19 @@ struct mgl_texture { int max_width; int max_height; bool pixel_coordinates; - bool mipmap; + mgl_texture_scale_type scale_type; bool owned; }; typedef struct { bool compressed; /* false by default */ bool pixel_coordinates; /* false by default, texture coordinates are normalized */ - bool mipmap; /* false by default, generate mipmaps (available since opengl 3.0) */ + mgl_texture_scale_type scale_type; /* MGL_TEXTURE_SCALE_LINEAR by default */ } mgl_texture_load_options; typedef struct { bool pixel_coordinates; /* false by default, texture coordinates are normalized */ + mgl_texture_scale_type scale_type; /* MGL_TEXTURE_SCALE_LINEAR by default */ } mgl_texture_reference_options; int mgl_texture_init(mgl_texture *self); -- cgit v1.2.3-70-g09d2