Skip to content

Commit fa5ee72

Browse files
authored
Consider current RTT state for screenToBlob (#6867)
1 parent 72ed863 commit fa5ee72

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

code/graphics/opengl/gropengl.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,21 @@ SCP_string gr_opengl_blob_screen()
337337
GLuint pbo = 0;
338338

339339
GL_state.PushFramebufferState();
340-
GL_state.BindFrameBuffer(Cmdline_window_res ? Back_framebuffer : 0, GL_FRAMEBUFFER);
340+
341+
GLuint source_fbo = 0;
342+
343+
GLuint render_target = opengl_get_rtt_framebuffer();
344+
if (render_target != 0) {
345+
source_fbo = render_target;
346+
}
347+
else if (Cmdline_window_res) {
348+
source_fbo = Back_framebuffer;
349+
}
350+
351+
GL_state.BindFrameBuffer(source_fbo, GL_FRAMEBUFFER);
341352

342353
//Reading from the front buffer here seems to no longer work correctly; that just reads back all zeros
343-
glReadBuffer(Cmdline_window_res ? GL_COLOR_ATTACHMENT0 : GL_FRONT);
354+
glReadBuffer(source_fbo != 0 ? GL_COLOR_ATTACHMENT0 : GL_FRONT);
344355

345356
// now for the data
346357
if (Use_PBOs) {

0 commit comments

Comments
 (0)