summaryrefslogtreecommitdiff
path: root/src/apps/qcam/viewfinder_gl.cpp
AgeCommit message (Collapse)Author
10 daysqcam: viewfinder_gl: Render image centered in letterboxLaurent Pinchart
Mimic the letterbox behaviour of the Qt viewfinder by rendering the image centered. This is done by adding a projection matrix to the vertex shader to scale the rendered rectangle. Another option would have been to keep using glViewport() (which would have needed to be moved to paintGL(), as Qt resets the viewport to span the full widget before calling). Hidpi displays would then need special handling of the device pixel ratio, which is done automatically by Qt when it sets the default viewport. Using a projection matrix avoids this complication. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
10 daysqcam: viewfinder_gl: Drop duplicate glClearColor()Laurent Pinchart
There's no need to call glClearColor() twice before drawing any GL content. Drop the first call. This doesn't introduce any functional change. While at it, pass floats instead of doubles to glClearColor(), as required by the function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
10 daysqcam: viewfinder_gl: Fix binding of vertex buffer and shader programLaurent Pinchart
Starting in Qt 6.7.0, vertex buffers and shader programs are unbound just before calling QOpenGLWidget::paintGL(). This breaks rendering in the GL viewfinder in two ways. First, we bind the vertex buffer only once at initialization time. There is therefore no vertex buffer mapped at rendering time, preventing both the vertex shader from having access to the vertex and texture coordinates. Then, we bind the shader program only when rendering the first frame. There is thus no shader program bound for all subsequent frames, breaking rendering. Fix this by binding the vertex buffer where needed, when setting attribute buffers for the shader program, and binding the shader program for every frame. As we use a single vertex buffer, we could bind it at the beginning of paintGL() and keep it bound indefinitely. That would however fail to clearly indicate in the source code where the vertex buffer is needed, making the code more difficult to understand as it would rely on implicit assumptions. Release the vertex buffer explicitly when we don't need it anymore to avoid this. While at it, fix a coding style violation by adding missing curly brackets. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-05-09libcamera: Drop remaining file name from header comment blocksLaurent Pinchart
Source files in libcamera start by a comment block header, which includes the file name and a one-line description of the file contents. While the latter is useful to get a quick overview of the file contents at a glance, the former is mostly a source of inconvenience. The name in the comments can easily get out of sync with the file name when files are renamed, and copy & paste during development have often lead to incorrect names being used to start with. Readers of the source code are expected to know which file they're looking it. Drop the file name from the header comment blocks in all remaining locations that were not caught by the automated script as they are out of sync with the file name. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2022-10-24apps: Share common source between applicationsLaurent Pinchart
Multiple source files in the src/apps/cam/ directory are used by cam, qcam and lc-compliance. They are compiled separately for each application. Move them to a new src/apps/common/ directory and compile them in a static library to decrease the number of compilation operations. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-20Move test applications to src/apps/Laurent Pinchart
The cam and qcam test application share code, currently through a crude hack that references the cam source files directly from the qcam meson.build file. To prepare for the introduction of hosting that code in a static library, move all applications to src/apps/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>