[retro-gtk/wip/aplazas/gl-display: 9/10] colorful blinking square
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/gl-display: 9/10] colorful blinking square
- Date: Mon, 13 Nov 2017 14:11:55 +0000 (UTC)
commit 9770671e9385ab3ee7ee65055a12eac6b52577ff
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Nov 13 13:13:33 2017 +0100
colorful blinking square
retro-gtk/retro-gl-display.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/retro-gtk/retro-gl-display.c b/retro-gtk/retro-gl-display.c
index 9b1e448..c61ba40 100644
--- a/retro-gtk/retro-gl-display.c
+++ b/retro-gtk/retro-gl-display.c
@@ -70,9 +70,15 @@ retro_gl_display_get_video_box (RetroGLDisplay *self,
}
float vertices[] = {
- 0.0f, 0.5f, 1.0f, 0.0f, 0.0f, // Vertex 1: Red
- 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, // Vertex 2: Green
- -0.5f, -0.5f, 0.0f, 0.0f, 1.0f // Vertex 3: Blue
+ -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, // Top-left
+ 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, // Top-right
+ 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, // Bottom-right
+ -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, // Bottom-left
+};
+
+GLuint elements[] = {
+ 0, 1, 2,
+ 2, 3, 0,
};
static void
@@ -80,6 +86,7 @@ retro_gl_display_realize (RetroGLDisplay *self)
{
GLuint vertex_buffer_object;
GLuint vertex_array_object;
+ GLuint element_buffer_object;
GLuint vertex_shader;
GLuint fragment_shader;
GLuint shader_program;
@@ -95,6 +102,10 @@ retro_gl_display_realize (RetroGLDisplay *self)
glGenVertexArrays (1, &vertex_array_object);
glBindVertexArray (vertex_array_object);
+ glGenBuffers (1, &element_buffer_object);
+ glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, element_buffer_object);
+ glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (elements), elements, GL_STATIC_DRAW);
+
// Prepare the vertex shader
shader_source_bytes = g_resources_lookup_data ("/org/gnome/Retro/retro-gl-display-vertex.glsl", 0, NULL);
shader_source = g_bytes_get_data (shader_source_bytes, NULL);
@@ -179,7 +190,8 @@ retro_gl_display_render (RetroGLDisplay *self)
filter);
glBindFramebuffer (GL_READ_FRAMEBUFFER, 0);
- glDrawArrays (GL_TRIANGLES, 0, 3);
+ /* glDrawArrays (GL_TRIANGLES, 0, 3); */
+ glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]