summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-11-22 10:12:58 -0800
committerJasper St. Pierre <jstpierre@mecheye.net>2014-11-22 10:17:43 -0800
commit6ffba866a61dfcd854711c97e93dce641cb055b1 (patch)
tree500699e678a68190fd4a7f95e45be3b81cdc5149 /gdk
parent37ad6e11477060c74c2818210583b6fa37b1b027 (diff)
downloadgtk+-6ffba866a61dfcd854711c97e93dce641cb055b1.tar.gz
gdkgl: Use one VBO for both position and uv attributes
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkgl.c28
-rw-r--r--gdk/gdkglcontextprivate.h1
2 files changed, 7 insertions, 22 deletions
diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
index 78be22354d..b9563a66a3 100644
--- a/gdk/gdkgl.c
+++ b/gdk/gdkgl.c
@@ -223,9 +223,6 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
if (paint_data->tmp_vertex_buffer == 0)
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
- if (paint_data->tmp_uv_buffer == 0)
- glGenBuffers(1, &paint_data->tmp_uv_buffer);
-
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
use_texture_rect_program (paint_data);
else
@@ -239,32 +236,21 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
glEnableVertexAttribArray (0);
glEnableVertexAttribArray (1);
glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_vertex_buffer);
- glVertexAttribPointer (program->position_location, 2, GL_FLOAT, GL_FALSE, 0, NULL);
- glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_uv_buffer);
- glVertexAttribPointer (program->uv_location, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+
+ glVertexAttribPointer (program->position_location, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, NULL);
+ glVertexAttribPointer (program->uv_location, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, NULL + sizeof(float) * 2);
for (i = 0; i < n_quads; i++)
{
GdkTexturedQuad *quad = &quads[i];
float vertex_buffer_data[] = {
- (quad->x2 * 2) / w - 1, (quad->y1 * 2) / h - 1,
- (quad->x2 * 2) / w - 1, (quad->y2 * 2) / h - 1,
- (quad->x1 * 2) / w - 1, (quad->y2 * 2) / h - 1,
- (quad->x1 * 2) / w - 1, (quad->y1 * 2) / h - 1,
- };
- float uv_buffer_data[] = {
- quad->u2, quad->v1,
- quad->u2, quad->v2,
- quad->u1, quad->v2,
- quad->u1, quad->v1,
+ (quad->x2 * 2) / w - 1, (quad->y1 * 2) / h - 1, quad->u2, quad->v1,
+ (quad->x2 * 2) / w - 1, (quad->y2 * 2) / h - 1, quad->u2, quad->v2,
+ (quad->x1 * 2) / w - 1, (quad->y2 * 2) / h - 1, quad->u1, quad->v2,
+ (quad->x1 * 2) / w - 1, (quad->y1 * 2) / h - 1, quad->u1, quad->v1,
};
- glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_vertex_buffer);
glBufferData (GL_ARRAY_BUFFER, sizeof(vertex_buffer_data), vertex_buffer_data, GL_STREAM_DRAW);
-
- glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_uv_buffer);
- glBufferData (GL_ARRAY_BUFFER, sizeof(uv_buffer_data), uv_buffer_data, GL_STREAM_DRAW);
-
glDrawArrays (GL_TRIANGLE_FAN, 0, 4);
}
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index ebe5e18883..7f5f574fac 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -59,7 +59,6 @@ typedef struct {
guint vertex_array_object;
guint tmp_framebuffer;
guint tmp_vertex_buffer;
- guint tmp_uv_buffer;
GdkGLContextProgram texture_2d_quad_program;
GdkGLContextProgram texture_rect_quad_program;