GPUTexture: Add Mipmap Control functions.
This commit is contained in:
@@ -176,8 +176,10 @@ void GPU_texture_bind(GPUTexture *tex, int number);
|
||||
void GPU_texture_unbind(GPUTexture *tex);
|
||||
int GPU_texture_bound_number(GPUTexture *tex);
|
||||
|
||||
void GPU_texture_generate_mipmap(GPUTexture *tex);
|
||||
void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare);
|
||||
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter);
|
||||
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap);
|
||||
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat);
|
||||
|
||||
struct GPUFrameBuffer *GPU_texture_framebuffer(GPUTexture *tex);
|
||||
|
||||
@@ -722,6 +722,25 @@ int GPU_texture_bound_number(GPUTexture *tex)
|
||||
return tex->number;
|
||||
}
|
||||
|
||||
void GPU_texture_generate_mipmap(GPUTexture *tex)
|
||||
{
|
||||
if (tex->number >= GPU_max_textures()) {
|
||||
fprintf(stderr, "Not enough texture slots.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tex->number == -1)
|
||||
return;
|
||||
|
||||
if (tex->number != 0)
|
||||
glActiveTexture(GL_TEXTURE0 + tex->number);
|
||||
|
||||
glGenerateMipmap(tex->target_base);
|
||||
|
||||
if (tex->number != 0)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare)
|
||||
{
|
||||
if (tex->number >= GPU_max_textures()) {
|
||||
@@ -764,6 +783,26 @@ void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap)
|
||||
{
|
||||
if (tex->number >= GPU_max_textures()) {
|
||||
fprintf(stderr, "Not enough texture slots.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tex->number == -1)
|
||||
return;
|
||||
|
||||
if (tex->number != 0)
|
||||
glActiveTexture(GL_TEXTURE0 + tex->number);
|
||||
|
||||
GLenum mipmap = use_mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
|
||||
glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, mipmap);
|
||||
|
||||
if (tex->number != 0)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat)
|
||||
{
|
||||
if (tex->number >= GPU_max_textures()) {
|
||||
|
||||
Reference in New Issue
Block a user