From patchwork Tue Feb 8 11:10:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 84 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:39:51 -0000 Delivered-To: patches@linaro.org Received: by 10.147.124.5 with SMTP id b5cs87028yan; Tue, 8 Feb 2011 03:10:23 -0800 (PST) Received: by 10.216.48.70 with SMTP id u48mr6947565web.25.1297163423117; Tue, 08 Feb 2011 03:10:23 -0800 (PST) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id o67si8391366wej.69.2011.02.08.03.10.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Feb 2011 03:10:23 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) smtp.mail=alexandros.frantzis@linaro.org Received: by mail-ww0-f50.google.com with SMTP id 26so5658906wwf.31 for ; Tue, 08 Feb 2011 03:10:22 -0800 (PST) Received: by 10.216.21.66 with SMTP id q44mr15597356weq.10.1297163422696; Tue, 08 Feb 2011 03:10:22 -0800 (PST) Received: from localhost ([194.219.210.40]) by mx.google.com with ESMTPS id i80sm2759835wej.28.2011.02.08.03.10.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Feb 2011 03:10:22 -0800 (PST) From: alexandros.frantzis@linaro.org To: cairo@cairographics.org Subject: [PATCH 2/6] gl: Add function to bind a 4x4 float matrix shader uniform Date: Tue, 8 Feb 2011 13:10:11 +0200 Message-Id: <1297163415-31035-3-git-send-email-alexandros.frantzis@linaro.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1297163415-31035-1-git-send-email-alexandros.frantzis@linaro.org> References: <1297163415-31035-1-git-send-email-alexandros.frantzis@linaro.org> From: Alexandros Frantzis --- src/cairo-gl-private.h | 5 +++++ src/cairo-gl-shaders.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 04322f2..3dd75f8 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -523,6 +523,11 @@ _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx, cairo_matrix_t* m); cairo_private void +_cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx, + const char *name, + GLfloat* gl_m); + +cairo_private void _cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx, const char *name, GLuint tex_unit); diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index a39883d..1b10b04 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -93,6 +93,12 @@ typedef struct cairo_gl_shader_impl { cairo_matrix_t* m); void + (*bind_matrix4f) (cairo_gl_context_t *ctx, + cairo_gl_shader_t *shader, + const char *name, + GLfloat* gl_m); + + void (*bind_texture) (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader, const char *name, @@ -263,6 +269,18 @@ bind_matrix_core_2_0 (cairo_gl_context_t *ctx, } static void +bind_matrix4f_core_2_0 (cairo_gl_context_t *ctx, + cairo_gl_shader_t *shader, + const char *name, + GLfloat* gl_m) +{ + cairo_gl_dispatch_t *dispatch = &ctx->dispatch; + GLint location = dispatch->GetUniformLocation (shader->program, name); + assert (location != -1); + dispatch->UniformMatrix4fv (location, 1, GL_FALSE, gl_m); +} + +static void bind_texture_core_2_0 (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader, const char *name, cairo_gl_tex_t tex_unit) { @@ -292,6 +310,7 @@ static const cairo_gl_shader_impl_t shader_impl_core_2_0 = { bind_vec3_core_2_0, bind_vec4_core_2_0, bind_matrix_core_2_0, + bind_matrix4f_core_2_0, bind_texture_core_2_0, use_program_core_2_0, }; @@ -798,6 +817,13 @@ _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx, } void +_cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx, + const char *name, GLfloat* gl_m) +{ + ctx->shader_impl->bind_matrix4f (ctx, ctx->current_shader, name, gl_m); +} + +void _cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx, const char *name, GLuint tex_unit) {