Merge pull request #1514 from aliaspider/master

small fix for gl_read_frame_raw/screenshot code.
This commit is contained in:
Twinaphex 2015-03-16 16:03:35 +01:00
commit c1b1ff46e0
2 changed files with 29 additions and 11 deletions

View File

@ -2768,28 +2768,41 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
static void* gl_read_frame_raw(void *data, unsigned *width_p,
unsigned *height_p, size_t *pitch_p)
{
#ifdef HAVE_FBO
void* buffer;
#endif
void* buffer_texture;
int i;
gl_t *gl = (gl_t*)data;
unsigned width = gl->last_width[gl->tex_index];
unsigned width = gl->last_width[gl->tex_index];
unsigned height = gl->last_height[gl->tex_index];
size_t pitch = gl->tex_w * gl->base_size;
void* buffer = malloc(pitch * height);
void* buffer_texture = malloc(pitch * gl->tex_h);
size_t pitch = gl->tex_w * gl->base_size;
#ifdef HAVE_FBO
if (gl->hw_render_use)
buffer = malloc(pitch * height);
#endif
buffer_texture = malloc(pitch * gl->tex_h);
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
glGetTexImage(GL_TEXTURE_2D, 0,gl->texture_type, gl->texture_fmt, buffer_texture);
for(i = 0; i < height ; i++)
memcpy((uint8_t*)buffer + i * pitch,
(uint8_t*)buffer_texture + (height - 1 - i) * pitch, pitch);
*width_p = width;
*height_p = height;
*pitch_p = pitch;
free(buffer_texture);
return buffer;
#ifdef HAVE_FBO
if (gl->hw_render_use)
{
for(i = 0; i < height ; i++)
memcpy((uint8_t*)buffer + i * pitch,
(uint8_t*)buffer_texture + (height - 1 - i) * pitch, pitch);
free(buffer_texture);
return buffer;
}
#endif
return buffer_texture;
}
#endif

View File

@ -294,13 +294,18 @@ bool take_screenshot(void)
free(frame_data);
}
else
RARCH_ERR(RETRO_LOG_TAKE_SCREENSHOT_ERROR);
ret = false;
g_extern.frame_cache.data = old_data;
g_extern.frame_cache.width = old_width;
g_extern.frame_cache.height = old_height;
g_extern.frame_cache.pitch = old_pitch;
}
else
{
RARCH_ERR(RETRO_LOG_TAKE_SCREENSHOT_ERROR);
ret = false;
}
if (ret)