From 28eaf11cf3b220871b97d9ba40d5058a84bcba09 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Oct 2011 20:46:01 +0200 Subject: vo_gl: implement screenshots --- libvo/gl_common.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libvo/gl_common.c') diff --git a/libvo/gl_common.c b/libvo/gl_common.c index bbcbeb2f3b..f433f5642d 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -71,6 +71,7 @@ void glAdjustAlignment(GL *gl, int stride) else gl_alignment = 1; gl->PixelStorei(GL_UNPACK_ALIGNMENT, gl_alignment); + gl->PixelStorei(GL_PACK_ALIGNMENT, gl_alignment); } struct gl_name_map_struct { @@ -634,6 +635,24 @@ void glUploadTex(GL *gl, GLenum target, GLenum format, GLenum type, gl->TexSubImage2D(target, 0, x, y, w, y_max - y, format, type, data); } +/** + * \brief download a texture, handling things like stride and slices + * \param target texture target, usually GL_TEXTURE_2D + * \param format OpenGL format of data + * \param type OpenGL type of data + * \param dataptr destination memory for download + * \param stride data stride (must be positive) + * \ingroup gltexture + */ +void glDownloadTex(GL *gl, GLenum target, GLenum format, GLenum type, + void *dataptr, int stride) +{ + // this is not always correct, but should work for MPlayer + glAdjustAlignment(gl, stride); + gl->PixelStorei(GL_PACK_ROW_LENGTH, stride / glFmt2bpp(format, type)); + gl->GetTexImage(target, 0, format, type, dataptr); +} + /** * \brief Setup ATI version of register combiners for YUV to RGB conversion. * \param csp_params parameters used for colorspace conversion -- cgit v1.2.3