diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-16 21:56:17 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-18 04:43:51 +0300 |
commit | 2840782d8478f1c37c2aa91cc7f12c8e1f4dca0a (patch) | |
tree | b6da922d89a166fd1653e273f7bf6eb346c3d25c /source/blender/gpu | |
parent | 02c09773ea07c8c0a3d7be63abdfd963a9452402 (diff) |
Cleanup: GPU: Make icon drawing use GPUTexture
This remove all gl function calls. Adds a new sampler only
for icon drawing.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_texture.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.c | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index a13f61177e6..f9e129b2f7a 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -298,6 +298,8 @@ int GPU_texture_opengl_bindcode(const GPUTexture *tex); void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size); +void GPU_sampler_icon_bind(int number); + #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 56e82b94fd2..251a4d71597 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -52,6 +52,7 @@ static struct GPUTextureGlobal { GPUTexture *invalid_tex_3D; /** Sampler objects used to replace internal texture parameters. */ GLuint samplers[GPU_SAMPLER_MAX]; + GLuint icon_sampler; } GG = {NULL}; /* Maximum number of FBOs a texture can be attached to. */ @@ -2176,11 +2177,23 @@ void GPU_samplers_init(void) * - GL_TEXTURE_LOD_BIAS is 0.0f. **/ } + + /* Custom sampler for icons. */ + glGenSamplers(1, &GG.icon_sampler); + glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f); +} + +void GPU_sampler_icon_bind(int unit) +{ + glBindSampler(unit, GG.icon_sampler); } void GPU_samplers_free(void) { glDeleteSamplers(GPU_SAMPLER_MAX, GG.samplers); + glDeleteSamplers(1, &GG.icon_sampler); } /** \} */ |