Cleanup: GPU: Wrap GL_UNPACK_ROW_LENGTH in GPU_state
Also go back to default value of 0 after usage.
This commit is contained in:
parent
faeaf53255
commit
35f1b3e43b
|
@ -120,9 +120,6 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
|
|||
type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
GLint unpack_row_length;
|
||||
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpack_row_length);
|
||||
|
||||
eGPUTextureFormat gpu_format = (type == GL_FLOAT) ? GPU_RGBA16F : GPU_RGBA8;
|
||||
eGPUDataFormat gpu_data = (type == GL_FLOAT) ? GPU_DATA_FLOAT : GPU_DATA_UNSIGNED_BYTE;
|
||||
GPUTexture *texture = GPU_texture_create_nD(
|
||||
|
@ -165,7 +162,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
|
|||
immUniformColor4fv((color) ? color : white);
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w);
|
||||
GPU_unpack_row_length_set(img_w);
|
||||
|
||||
for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
|
||||
for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) {
|
||||
|
@ -259,7 +256,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
|
|||
GPU_texture_unbind(texture);
|
||||
GPU_texture_free(texture);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length);
|
||||
/* Restore default. */
|
||||
GPU_unpack_row_length_set(0);
|
||||
}
|
||||
|
||||
void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
|
||||
|
|
|
@ -69,6 +69,7 @@ void GPU_color_mask(bool r, bool g, bool b, bool a);
|
|||
void GPU_depth_mask(bool depth);
|
||||
bool GPU_depth_mask_get(void);
|
||||
void GPU_stencil_mask(uint stencil);
|
||||
void GPU_unpack_row_length_set(uint len);
|
||||
|
||||
void GPU_flush(void);
|
||||
void GPU_finish(void);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue