summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2017-01-26 09:33:34 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2017-01-26 09:33:34 +0200
commitcf82d357a09cfeade52f652f7e8a47e674ced28d (patch)
tree1a1a81f5327b1ca7adc8d7157aa804096bb61729
parent65f107686e6449de6b3cb603397a7f2aa0e60f8b (diff)
Bit safer glIsBuffer
-rw-r--r--glcapture.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/glcapture.c b/glcapture.c
index d1c7b89..5fb7cb9 100644
--- a/glcapture.c
+++ b/glcapture.c
@@ -362,6 +362,12 @@ flip_pixels_if_needed(const GLint view[4], uint8_t *pixels, const uint32_t width
}
}
+static bool
+is_buffer(GLuint obj)
+{
+ return (obj > 0 && glIsBuffer(obj));
+}
+
static void
capture_frame_pbo(struct gl *gl, const GLint view[4], const uint64_t ts)
{
@@ -378,7 +384,7 @@ capture_frame_pbo(struct gl *gl, const GLint view[4], const uint64_t ts)
.components = (OPENGL_VARIANT == OPENGL_ES ? 4 : 3),
};
- if (!glIsBuffer(gl->pbo[gl->active].obj)) {
+ if (!is_buffer(gl->pbo[gl->active].obj)) {
WARNX("create pbo %u", gl->active);
glGenBuffers(1, &gl->pbo[gl->active].obj);
}
@@ -408,12 +414,12 @@ capture_frame_pbo(struct gl *gl, const GLint view[4], const uint64_t ts)
gl->pbo[gl->active].ts = ts;
gl->pbo[gl->active].width = view[2];
gl->pbo[gl->active].height = view[3];
- gl->pbo[gl->active].written = true;
+ gl->pbo[gl->active].written = (glGetError() == GL_NO_ERROR);
, 1.0, "read_frame");
gl->active = (gl->active + 1) % NUM_PBOS;
- if (glIsBuffer(gl->pbo[gl->active].obj) && gl->pbo[gl->active].written) {
+ if (is_buffer(gl->pbo[gl->active].obj) && gl->pbo[gl->active].written) {
const struct frame_info info = {
.ts = gl->pbo[gl->active].ts,
.stream = STREAM_VIDEO,
@@ -441,7 +447,7 @@ static void
reset_capture(struct gl *gl)
{
for (size_t i = 0; i < NUM_PBOS; ++i) {
- if (glIsBuffer(gl->pbo[i].obj))
+ if (is_buffer(gl->pbo[i].obj))
glDeleteBuffers(1, &gl->pbo[i].obj);
}