[retro-gtk/wip/aplazas/gl-display: 5/12] pixdata: Add the load_gl_texture() method
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/gl-display: 5/12] pixdata: Add the load_gl_texture() method
- Date: Sat, 18 Nov 2017 09:40:35 +0000 (UTC)
commit 7b778f52532c34e98c965446eca9358c81dcf074
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sat Nov 18 08:01:05 2017 +0100
pixdata: Add the load_gl_texture() method
retro-gtk/retro-pixdata.c | 27 +++++++++++++++++++++++++++
retro-gtk/retro-pixdata.h | 1 +
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/retro-pixdata.c b/retro-gtk/retro-pixdata.c
index fa38c31..4927ea3 100644
--- a/retro-gtk/retro-pixdata.c
+++ b/retro-gtk/retro-pixdata.c
@@ -2,6 +2,8 @@
#include "retro-pixdata-private.h"
+#include <epoxy/gl.h>
+
G_DEFINE_BOXED_TYPE (RetroPixdata, retro_pixdata, retro_pixdata_copy, retro_pixdata_free)
/*
@@ -352,3 +354,28 @@ retro_pixdata_to_pixbuf (RetroPixdata *self)
return pixbuf;
}
+
+/**
+ * retro_pixdata_load_gl_texture:
+ * @self: the #RetroPixdata
+ *
+ * Loads an OpenGL texture from @self.
+ *
+ * Returns: whether the loading was successful
+ */
+gboolean
+retro_pixdata_load_gl_texture (RetroPixdata *self)
+{
+ g_return_val_if_fail (self != NULL, FALSE);
+
+ glTexImage2D (GL_TEXTURE_2D,
+ 0,
+ GL_RGB,
+ self->width,
+ self->height,
+ 0,
+ GL_BGRA, GL_UNSIGNED_BYTE,
+ self->data);
+
+ return TRUE;
+}
diff --git a/retro-gtk/retro-pixdata.h b/retro-gtk/retro-pixdata.h
index 8c4d13e..3b0b9a8 100644
--- a/retro-gtk/retro-pixdata.h
+++ b/retro-gtk/retro-pixdata.h
@@ -24,6 +24,7 @@ gint retro_pixdata_get_width (RetroPixdata *self);
gint retro_pixdata_get_height (RetroPixdata *self);
gfloat retro_pixdata_get_aspect_ratio (RetroPixdata *self);
GdkPixbuf *retro_pixdata_to_pixbuf (RetroPixdata *self);
+gboolean retro_pixdata_load_gl_texture (RetroPixdata *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RetroPixdata, retro_pixdata_free)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]