Mipmapping & texture compression options
This commit is contained in:
parent
5e0966beb8
commit
4afe4f3fbe
45
src/k3.c
45
src/k3.c
@ -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,22 +2494,28 @@ void k3Init() {
|
|||||||
, NULL), NULL);
|
, NULL), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(GLAD_GL_KHR_texture_compression_astc_ldr) {
|
if(enableTextureCompression) {
|
||||||
TextureCompressionEnabled = true;
|
/*if(GLAD_GL_KHR_texture_compression_astc_ldr) {
|
||||||
|
TextureCompressionEnabled = true;
|
||||||
|
|
||||||
} else */ if(GLAD_GL_ARB_texture_compression_bptc || GLAD_GL_VERSION_4_2) {
|
|
||||||
TextureCompressionEnabled = true;
|
} else */ if(GLAD_GL_ARB_texture_compression_bptc || GLAD_GL_VERSION_4_2) {
|
||||||
|
TextureCompressionEnabled = true;
|
||||||
TextureCompressionSRGBA = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
|
|
||||||
TextureCompressionRGBA = GL_COMPRESSED_RGBA_BPTC_UNORM;
|
TextureCompressionSRGBA = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
|
||||||
TextureOfflineCompressor = compress_rgba_bc7;
|
TextureCompressionRGBA = GL_COMPRESSED_RGBA_BPTC_UNORM;
|
||||||
} else if(GL_EXT_texture_compression_s3tc) {
|
TextureOfflineCompressor = compress_rgba_bc7;
|
||||||
TextureCompressionEnabled = true;
|
} else if(GL_EXT_texture_compression_s3tc) {
|
||||||
|
TextureCompressionEnabled = true;
|
||||||
TextureCompressionSRGBA = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
|
||||||
TextureCompressionRGBA = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
TextureCompressionSRGBA = GL_COMPRESSED_SRGB_ALPHA_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;
|
||||||
|
Loading…
Reference in New Issue
Block a user