16#include <libcamera/base/span.h>
25#define EGL_EGLEXT_PROTOTYPES
27#include <EGL/eglext.h>
28#define GL_GLEXT_PROTOTYPES
30#include <GLES2/gl2ext.h>
61 eGLImage(GLint format, uint32_t width, uint32_t height, uint32_t stride, GLenum texture_unit, uint32_t texture_unit_uniform_id)
68 glGenFramebuffers(1, &
fbo_);
79 glDeleteFramebuffers(1, &
fbo_);
117 void pushEnv(std::vector<std::string> &shaderEnv,
const char *str);
121 Span<const std::string> shaderEnv);
123 Span<const std::string> shaderEnv);
124 int linkProgram(GLuint &programId, GLuint fragmentshaderId, GLuint vertexshaderId);
136 EGLDisplay display_ = EGL_NO_DISPLAY;
137 EGLContext context_ = EGL_NO_CONTEXT;
138 EGLSurface surface_ = EGL_NO_SURFACE;
140 static EGLDisplay probeDisplay();
141 int compileShader(
int shaderType, GLuint &shaderId, Span<const unsigned char> shaderData,
142 Span<const std::string> shaderEnv);
144 int createDMABufTexture2D(
eGLImage &eglImage,
int fd,
bool output);
146 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
147 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
148 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
149 PFNGLGETSTRINGPROC glGetString;
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Definition class.h:29
Helper class for managing EGL image resources.
Definition egl.h:50
uint32_t offset_
Definition egl.h:87
~eGLImage()
Destroy the eGLImage.
Definition egl.h:77
GLuint texture_
Definition egl.h:91
GLuint fbo_
Definition egl.h:92
uint32_t stride_
Definition egl.h:86
uint32_t height_
Definition egl.h:85
bool dmabuf_import_failed_
Definition egl.h:93
GLenum texture_unit_
Definition egl.h:90
eGLImage(GLint format, uint32_t width, uint32_t height, uint32_t stride, GLenum texture_unit, uint32_t texture_unit_uniform_id)
Construct an eGLImage with explicit stride.
Definition egl.h:61
uint32_t framesize_
Definition egl.h:88
GLint format_
Definition egl.h:83
uint32_t texture_unit_uniform_id_
Definition egl.h:89
uint32_t width_
Definition egl.h:84
Helper class for managing OpenGL ES operations.
Definition egl.h:100
static bool isAvailable()
Probe whether EGL surfaceless rendering is available.
Definition egl.cpp:336
void activateBindTexture(eGLImage &eglImage)
Activate a texture unit and bind a texture to that unit.
Definition egl.cpp:151
eGL()
Construct an EGL helper.
Definition egl.cpp:71
void flushOutput()
Flush the rendering pipeline.
Definition egl.cpp:108
int createInputDMABufTexture2D(eGLImage &eglImage, int fd)
Create an input DMA-BUF backed texture.
Definition egl.cpp:248
int linkProgram(GLuint &programId, GLuint fragmentshaderId, GLuint vertexshaderId)
Link a shader program.
Definition egl.cpp:654
int initEGLContext()
Initialise the EGL context.
Definition egl.cpp:386
int createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
Create an output DMA-BUF backed texture.
Definition egl.cpp:267
void pushEnv(std::vector< std::string > &shaderEnv, const char *str)
Add a preprocessor definition to shader environment.
Definition egl.cpp:517
void createOutputTexture2D(eGLImage &eglImage)
Create a 2D texture attached to an FBO for render-to-texture.
Definition egl.cpp:370
void makeCurrent()
Make the EGL context current for the calling thread.
Definition egl.cpp:472
int compileVertexShader(GLuint &shaderId, Span< const unsigned char > shaderData, Span< const std::string > shaderEnv)
Compile a vertex shader.
Definition egl.cpp:536
int attachTextureToFBO(eGLImage &eglImage)
Attach a texture to a frame-buffer-object.
Definition egl.cpp:124
void syncOutput()
Synchronise rendering output.
Definition egl.cpp:95
void useProgram(GLuint programId)
Activate a shader program for rendering.
Definition egl.cpp:488
~eGL()
Destroy the EGL helper.
Definition egl.cpp:80
void updateTexture2D(eGLImage &eglImage, void *data)
Update a 2D texture already created.
Definition egl.cpp:353
void dumpShaderSource(GLuint shaderId)
Dump shader source code to the log.
Definition egl.cpp:623
void createTexture2D(eGLImage &eglImage, void *data)
Create a 2D texture from a memory buffer.
Definition egl.cpp:284
void deleteProgram(GLuint programId)
Delete a shader program.
Definition egl.cpp:502
int compileFragmentShader(GLuint &shaderId, Span< const unsigned char > shaderData, Span< const std::string > shaderEnv)
Compile a fragment shader.
Definition egl.cpp:554
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:51
Top-level libcamera namespace.
Definition backtrace.h:17
Miscellaneous utility functions.