Fixed broken photo mode screenshots after window resize
This commit is contained in:
+26
-31
@@ -1016,40 +1016,35 @@ namespace rndr {
|
||||
}
|
||||
|
||||
void Render::take_ss(texture* tex, bool vertical, float_t horizontal_offset) {
|
||||
GLuint temp_tex;
|
||||
glGenTextures(1, &temp_tex);
|
||||
gl_state_active_bind_texture_2d(0, temp_tex);
|
||||
glTexParameteriDLL(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteriDLL(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glCopyTexImage2DDLL(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, width, height, 0);
|
||||
|
||||
int32_t index = render_texture_set(tex, true);
|
||||
if (index >= 0) {
|
||||
render_textures[index].Bind();
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
float_t x_min = 0.0f;
|
||||
float_t x_max = 1.0f;
|
||||
if (vertical) {
|
||||
const float_t center = 0.5f + horizontal_offset / (float_t)width;
|
||||
const float_t area = (float_t)height * (float_t)(9.0 / 16.0) / (float_t)width * 0.5f;
|
||||
x_min = center - area;
|
||||
x_max = center + area;
|
||||
}
|
||||
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
|
||||
glViewportDLL(0, 0, render_textures_data[index]->width, render_textures_data[index]->height);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
draw_quad(render_textures_data[index]->width, render_textures_data[index]->height,
|
||||
x_max, 1.0f, x_min, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
shader::unbind();
|
||||
gl_state_bind_framebuffer(0);
|
||||
gl_state_active_bind_texture_2d(0, 0);
|
||||
render_texture_free(tex, true);
|
||||
float_t x_min = 0.0f;
|
||||
float_t x_max = 1.0f;
|
||||
if (vertical) {
|
||||
const float_t center = 0.5f + horizontal_offset / (float_t)width;
|
||||
const float_t area = (float_t)height * (float_t)(9.0 / 16.0) / (float_t)width * 0.5f;
|
||||
x_min = center - area;
|
||||
x_max = center + area;
|
||||
}
|
||||
else
|
||||
gl_state_active_bind_texture_2d(0, 0);
|
||||
glDeleteTextures(1, &temp_tex);
|
||||
|
||||
render_textures[index].Bind();
|
||||
texture* rend_tex = render_textures_data[index];
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
|
||||
glViewportDLL(0, 0, rend_tex->width, rend_tex->height);
|
||||
gl_state_active_bind_texture_2d(0, rctx->screen_buffer.GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
draw_quad(rend_tex->width, rend_tex->height,
|
||||
x_max, 1.0f, x_min, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
shader::unbind();
|
||||
gl_state_bind_framebuffer(0);
|
||||
gl_state_active_bind_texture_2d(0, 0);
|
||||
gl_state_bind_sampler(0, 0);
|
||||
|
||||
render_texture_free(tex, true);
|
||||
}
|
||||
|
||||
void Render::transparency_combine(float_t alpha) {
|
||||
|
||||
@@ -911,16 +911,16 @@ namespace rndr {
|
||||
if (multisample && multisample_framebuffer) {
|
||||
gl_state_bind_framebuffer(0);
|
||||
gl_state_disable_multisample();
|
||||
fbo_blit(multisample_framebuffer, 0,
|
||||
fbo_blit(multisample_framebuffer, rctx->screen_buffer.fbos[0],
|
||||
0, 0, rctx->sprite_width, rctx->sprite_height,
|
||||
rctx->screen_x_offset, rctx->screen_y_offset,
|
||||
rctx->sprite_width, rctx->sprite_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
0, 0, rctx->sprite_width, rctx->sprite_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
else
|
||||
fbo_blit(rctx->screen_buffer.fbos[0], 0,
|
||||
0, 0, rctx->sprite_width, rctx->sprite_height,
|
||||
rctx->screen_x_offset, rctx->screen_y_offset,
|
||||
rctx->sprite_width, rctx->sprite_height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
fbo_blit(rctx->screen_buffer.fbos[0], 0,
|
||||
0, 0, rctx->sprite_width, rctx->sprite_height,
|
||||
rctx->screen_x_offset, rctx->screen_y_offset,
|
||||
rctx->sprite_width, rctx->sprite_height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
gl_state_get_error();
|
||||
|
||||
shader::unbind();
|
||||
|
||||
Reference in New Issue
Block a user