#include <fl_texture_gl.h>
Public Attributes | |
GObjectClass | parent_class |
: (out): name of texture. | |
Virtual method called when Flutter populates this texture. The OpenGL context used by Flutter has been already set. @texture: an #FlTexture. @target: texture target (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE). @width: (inout): width of the texture in pixels. @height: (inout): height of the texture in pixels. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore. Returns: TRUE on success. | |
gboolean(* | populate )(FlTextureGL *texture, uint32_t *target, uint32_t *name, uint32_t *width, uint32_t *height, GError **error) |
FlTextureGL:
#FlTextureGL is an abstract class that represents an OpenGL texture.
If you want to render textures in other OpenGL context, create and use the #GdkGLContext by calling gdk_window_create_gl_context () with the #GdkWindow of #FlView. The context will be shared with the one used by Flutter.
The following example shows how to implement an #FlTextureGL. ![ #include <epoxy/gl.h>
struct _MyTextureGL { FlTextureGL parent_instance;
GLuint texture_id; };
G_DEFINE_TYPE(MyTextureGL, my_texture_gl, fl_texture_gl_get_type ())
static gboolean my_texture_gl_populate (FlTextureGL *texture, uint32_t *target, uint32_t *name, uint32_t *width, uint32_t *height, GError **error) { MyTextureGL *self = MY_TEXTURE_GL (texture); if (self->texture_id == 0) { glGenTextures (1, &self->texture_id); glBindTexture (GL_TEXTURE_2D, self->texture_id); // further configuration here. } else { glBindTexture (GL_TEXTURE_2D, self->texture_id); }
// For example, we render pixel buffer here. // Note that Flutter only accepts textures in GL_RGBA8 format. static char buffer[] = { 0x1f, 0x2f, 0x3f, 0x4f }; // 1x1 pixel. glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
*target = GL_TEXTURE_2D; *name = self->texture_id; *width = 1; *height = 1;
return TRUE; }
static void my_texture_class_init(MyTextureClass* klass) { FL_TEXTURE_GL_CLASS(klass)->populate = my_texture_gl_populate; }
static void my_texture_init(MyTexture* self) {} ]|
Definition at line 83 of file fl_texture_gl.h.
GObjectClass _FlTextureGLClass::parent_class |
Definition at line 84 of file fl_texture_gl.h.
gboolean(* _FlTextureGLClass::populate) (FlTextureGL *texture, uint32_t *target, uint32_t *name, uint32_t *width, uint32_t *height, GError **error) |
Definition at line 99 of file fl_texture_gl.h.