diff options
author | wm4 <wm4@nowhere> | 2012-09-28 21:25:26 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-16 07:26:30 +0200 |
commit | 3c9c1790fee177cc9c9661475746a92ab6ce9bea (patch) | |
tree | 9939309bb9341f2684ab1fd9e2793a230369a674 /libvo/gl_common.c | |
parent | ffb7a2fe17af204635db6694b5b49b6368be91e6 (diff) | |
download | mpv-3c9c1790fee177cc9c9661475746a92ab6ce9bea.tar.bz2 mpv-3c9c1790fee177cc9c9661475746a92ab6ce9bea.tar.xz |
vo_gl3: support RGBA EOSD
This also adds support for multiple EOSD renderers. This capability is
unused yet, but important for the following commits.
Diffstat (limited to 'libvo/gl_common.c')
-rw-r--r-- | libvo/gl_common.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 1ad7017e10..c56b0c8ffc 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -427,6 +427,7 @@ static const extfunc_desc_t extfuncs[] = { DEF_GL3_DESC(FramebufferTexture2D), DEF_GL3_DESC(Uniform1f), DEF_GL3_DESC(Uniform3f), + DEF_GL3_DESC(Uniform4f), DEF_GL3_DESC(Uniform1i), DEF_GL3_DESC(UniformMatrix3fv), DEF_GL3_DESC(UniformMatrix4x3fv), @@ -674,6 +675,31 @@ void glUploadTex(GL *gl, GLenum target, GLenum format, GLenum type, gl->TexSubImage2D(target, 0, x, y, w, y_max - y, format, type, data); } +// Like glUploadTex, but upload a byte array with all elements set to val. +// If scratch is not NULL, points to a resizeable talloc memory block than can +// be freely used by the function (for avoiding temporary memory allocations). +void glClearTex(GL *gl, GLenum target, GLenum format, GLenum type, + int x, int y, int w, int h, uint8_t val, void **scratch) +{ + int bpp = glFmt2bpp(format, type); + int stride = w * bpp; + int size = h * stride; + if (size < 1) + return; + void *data = scratch ? *scratch : NULL; + if (talloc_get_size(data) < size) + data = talloc_realloc(NULL, data, char *, size); + memset(data, val, size); + glAdjustAlignment(gl, stride); + gl->PixelStorei(GL_UNPACK_ROW_LENGTH, w); + gl->TexSubImage2D(target, 0, x, y, w, h, format, type, data); + if (scratch) { + *scratch = data; + } else { + talloc_free(data); + } +} + /** * \brief download a texture, handling things like stride and slices * \param target texture target, usually GL_TEXTURE_2D |