Mipmapping & texture compression options

This commit is contained in:
Mid 2025-09-13 12:00:29 +03:00
parent 5e0966beb8
commit 4afe4f3fbe
2 changed files with 30 additions and 17 deletions

View File

@ -34,6 +34,8 @@ static GLenum TextureCompressionRGBA;
static GLenum TextureCompressionSRGBA; static GLenum TextureCompressionSRGBA;
static TextureOfflineCompressorFunc TextureOfflineCompressor; static TextureOfflineCompressorFunc TextureOfflineCompressor;
static bool MipmappingEnabled;
void k3StorageRef(struct k3Storage *s) { void k3StorageRef(struct k3Storage *s) {
s->ref++; s->ref++;
} }
@ -571,6 +573,10 @@ void k3TexUpdate(struct k3Tex *tex, enum k3TexType type, int index, uint16_t wid
break; break;
} }
if(!MipmappingEnabled) {
mipmap = 0;
}
if(!tex->tex) { if(!tex->tex) {
glGenTextures(1, &tex->tex); glGenTextures(1, &tex->tex);
glBindTexture(target, tex->tex); glBindTexture(target, tex->tex);
@ -2429,7 +2435,7 @@ static void *compress_rgba_bc7(const void *pixels, uint16_t width, uint16_t heig
return output; return output;
} }
void k3Init() { void k3Init(bool enableTextureCompression, bool enableMipmapping) {
if(GLAD_GL_ARB_debug_output) { if(GLAD_GL_ARB_debug_output) {
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
glDebugMessageCallbackARB(GlCallback, NULL); glDebugMessageCallbackARB(GlCallback, NULL);
@ -2488,6 +2494,7 @@ void k3Init() {
, NULL), NULL); , NULL), NULL);
} }
if(enableTextureCompression) {
/*if(GLAD_GL_KHR_texture_compression_astc_ldr) { /*if(GLAD_GL_KHR_texture_compression_astc_ldr) {
TextureCompressionEnabled = true; TextureCompressionEnabled = true;
@ -2504,6 +2511,11 @@ void k3Init() {
TextureCompressionSRGBA = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; TextureCompressionSRGBA = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
TextureCompressionRGBA = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; TextureCompressionRGBA = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
} }
} else {
TextureCompressionEnabled = false;
}
MipmappingEnabled = enableMipmapping;
} }
static size_t preprocess(char *src, const char*(*ldr)(const char *fn), const char ***strs, GLuint **sizes) { static size_t preprocess(char *src, const char*(*ldr)(const char *fn), const char ***strs, GLuint **sizes) {
@ -2714,6 +2726,7 @@ struct k3GLSLP *k3ProgramGLSL(struct k3GLSLV *vs, struct k3GLSLF *fs, struct k3G
GLint uniformCount; GLint uniformCount;
glGetObjectParameterivARB(prog, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &uniformCount); glGetObjectParameterivARB(prog, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &uniformCount);
for(i = 0; i < uniformCount; i++) { for(i = 0; i < uniformCount; i++) {
int size; int size;
int type; int type;

View File

@ -11,7 +11,7 @@
#include<pthread.h> #include<pthread.h>
#endif #endif
void k3Init(); void k3Init(bool tc, bool mipmap);
void k3Resize(uint16_t width, uint16_t height); void k3Resize(uint16_t width, uint16_t height);
void k3Update(); void k3Update();