diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-17 19:51:26 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-18 04:43:52 +0300 |
commit | 35f1b3e43b37006486b94675466cf4260087e269 (patch) | |
tree | 948195fd46b9e2165081e1ecf792ae63b1ab2319 /source/blender/gpu/intern | |
parent | faeaf5325554e37981424ded5add7bf2df484c55 (diff) |
Cleanup: GPU: Wrap GL_UNPACK_ROW_LENGTH in GPU_state
Also go back to default value of 0 after usage.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.c | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 9fdb98cfbf6..e5f49555265 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -683,9 +683,7 @@ static void gpu_texture_update_unscaled(uchar *rect, { /* Partial update without scaling. Stride and offset are used to copy only a * subset of a possible larger buffer than what we are updating. */ - GLint row_length; - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); - glPixelStorei(GL_UNPACK_ROW_LENGTH, tex_stride); + GPU_unpack_row_length_set(tex_stride); if (layer >= 0) { if (rect_float == NULL) { @@ -724,7 +722,8 @@ static void gpu_texture_update_unscaled(uchar *rect, } } - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); + /* Restore default. */ + GPU_unpack_row_length_set(0); } static void gpu_texture_update_from_ibuf( diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index b52504eb492..8dc246904df 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -181,6 +181,11 @@ void GPU_finish(void) glFinish(); } +void GPU_unpack_row_length_set(uint len) +{ + glPixelStorei(GL_UNPACK_ROW_LENGTH, len); +} + void GPU_logic_op_xor_set(bool enable) { if (enable) { @@ -413,6 +418,7 @@ void GPU_state_init(void) glDisable(GL_CULL_FACE); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); /* Is default but better be explicit. */ glEnable(GL_MULTISAMPLE); |