|
|
|
@ -202,15 +202,9 @@ void CameraViewWidget::paintGL() { |
|
|
|
|
glClearColor(bg.redF(), bg.greenF(), bg.blueF(), bg.alphaF()); |
|
|
|
|
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); |
|
|
|
|
|
|
|
|
|
std::lock_guard lk(lock); |
|
|
|
|
|
|
|
|
|
if (latest_texture_id == -1) return; |
|
|
|
|
|
|
|
|
|
glViewport(0, 0, width(), height()); |
|
|
|
|
// sync with the PBO
|
|
|
|
|
if (wait_fence) { |
|
|
|
|
wait_fence->wait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
glBindVertexArray(frame_vao); |
|
|
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
|
@ -295,23 +289,20 @@ void CameraViewWidget::vipcThread() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (VisionBuf *buf = vipc_client->recv(nullptr, 1000)) { |
|
|
|
|
{ |
|
|
|
|
std::lock_guard lk(lock); |
|
|
|
|
if (!Hardware::EON()) { |
|
|
|
|
void *texture_buffer = gl_buffer->map(QOpenGLBuffer::WriteOnly); |
|
|
|
|
memcpy(texture_buffer, buf->addr, buf->len); |
|
|
|
|
gl_buffer->unmap(); |
|
|
|
|
|
|
|
|
|
// copy pixels from PBO to texture object
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture[buf->idx]->frame_tex); |
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, buf->width, buf->height, GL_RGB, GL_UNSIGNED_BYTE, 0); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
|
|
assert(glGetError() == GL_NO_ERROR); |
|
|
|
|
|
|
|
|
|
wait_fence.reset(new WaitFence()); |
|
|
|
|
} |
|
|
|
|
latest_texture_id = buf->idx; |
|
|
|
|
if (!Hardware::EON()) { |
|
|
|
|
void *texture_buffer = gl_buffer->map(QOpenGLBuffer::WriteOnly); |
|
|
|
|
memcpy(texture_buffer, buf->addr, buf->len); |
|
|
|
|
gl_buffer->unmap(); |
|
|
|
|
|
|
|
|
|
// copy pixels from PBO to texture object
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture[buf->idx]->frame_tex); |
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, buf->width, buf->height, GL_RGB, GL_UNSIGNED_BYTE, 0); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
|
|
assert(glGetError() == GL_NO_ERROR); |
|
|
|
|
// use glFinish to ensure that the texture has been uploaded.
|
|
|
|
|
glFinish(); |
|
|
|
|
} |
|
|
|
|
latest_texture_id = buf->idx; |
|
|
|
|
// Schedule update. update() will be invoked on the gui thread.
|
|
|
|
|
QMetaObject::invokeMethod(this, "update"); |
|
|
|
|
|
|
|
|
|