summaryrefslogtreecommitdiffstats
path: root/libvo/gl_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'libvo/gl_common.c')
-rw-r--r--libvo/gl_common.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 8af486d4eb..3031dc5967 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -46,6 +46,8 @@
#include "aspect.h"
#include "pnm_loader.h"
#include "options.h"
+#include "sub/sub.h"
+#include "bitmap_packer.h"
//! \defgroup glgeneral OpenGL general helper functions
@@ -904,6 +906,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
@@ -1853,7 +1880,7 @@ void glDisable3D(GL *gl, int type)
gl->ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
break;
case GL_3D_QUADBUFFER:
- gl->DrawBuffer(vo_doublebuffering ? GL_BACK : GL_FRONT);
+ gl->DrawBuffer(GL_BACK);
gl->GetIntegerv(GL_DRAW_BUFFER, &buffer);
switch (buffer) {
case GL_FRONT: