[cogl] Removes the cogl-current-matrix abstraction

The indirection through this API isn't necessary since we no longer
arbitrate between the OpenGL matrix API and Cogl's client side API.  Also it
doesn't help to maintain an OpenGL style matrix mode API for internal use
since it's awkward to keep restoring the MODELVIEW mode and easy enough to
directly work with the matrix stacks of interest.

This replaces use of the _cogl_current_matrix API with direct use of the
_cogl_matrix_stack API.  All the unused cogl_current_matrix API is removed
and the matrix utility code left in cogl-current-matrix.c was moved to
cogl.c.
This commit is contained in:
Robert Bragg 2009-10-13 23:09:42 +01:00
parent 9f7bf9fb4d
commit 5e5d94dfbe
15 changed files with 270 additions and 227 deletions

View File

@ -94,8 +94,6 @@ libclutter_cogl_la_SOURCES = \
cogl-bitmap-private.h \
cogl-bitmap.c \
cogl-bitmap-fallback.c \
cogl-current-matrix.c \
cogl-current-matrix.h \
cogl-primitives.h \
cogl-primitives.c \
cogl-bitmap-pixbuf.c \

View File

@ -321,9 +321,12 @@ _cogl_clip_stack_rebuild (void)
gint scissor_y0 = 0;
gint scissor_x1 = G_MAXINT;
gint scissor_y1 = G_MAXINT;
CoglMatrixStack *modelview_stack;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
modelview_stack = ctx->modelview_stack;
/* The current primitive journal does not support tracking changes to the
* clip stack... */
_cogl_journal_flush ();
@ -354,8 +357,8 @@ _cogl_clip_stack_rebuild (void)
{
CoglClipStackEntryPath *path = (CoglClipStackEntryPath *) entry;
cogl_push_matrix ();
_cogl_set_matrix (&path->matrix);
_cogl_matrix_stack_push (modelview_stack);
_cogl_matrix_stack_set (modelview_stack, &path->matrix);
_cogl_add_path_to_stencil_buffer (path->path_nodes_min,
path->path_nodes_max,
@ -363,7 +366,7 @@ _cogl_clip_stack_rebuild (void)
path->path,
using_stencil_buffer);
cogl_pop_matrix ();
_cogl_matrix_stack_pop (modelview_stack);
using_stencil_buffer = TRUE;
@ -374,8 +377,8 @@ _cogl_clip_stack_rebuild (void)
{
CoglClipStackEntryRect *rect = (CoglClipStackEntryRect *) entry;
cogl_push_matrix ();
_cogl_set_matrix (&rect->matrix);
_cogl_matrix_stack_push (modelview_stack);
_cogl_matrix_stack_set (modelview_stack, &rect->matrix);
/* If this is the first entry and we support clip planes then use
that instead */
@ -399,7 +402,7 @@ _cogl_clip_stack_rebuild (void)
using_stencil_buffer = TRUE;
}
cogl_pop_matrix ();
_cogl_matrix_stack_pop (modelview_stack);
}
else
{

View File

@ -66,6 +66,8 @@ cogl_create_context (void)
_context->indirect = gl_is_indirect;
_context->flushed_matrix_mode = COGL_MATRIX_MODELVIEW;
_context->modelview_stack = _cogl_matrix_stack_new ();
_context->projection_stack = _cogl_matrix_stack_new ();
_context->texture_units = NULL;
_context->default_material = cogl_material_new ();
@ -109,9 +111,6 @@ cogl_create_context (void)
/* Initialise the clip stack */
_cogl_clip_stack_state_init ();
/* Initialise matrix stack */
_cogl_current_matrix_state_init ();
/* Initialise the driver specific state */
_cogl_create_context_driver (_context);
@ -152,7 +151,8 @@ _cogl_destroy_context ()
_cogl_clip_stack_state_destroy ();
_cogl_current_matrix_state_destroy ();
_cogl_matrix_stack_destroy (_context->modelview_stack);
_cogl_matrix_stack_destroy (_context->projection_stack);
_cogl_destroy_texture_units ();

View File

@ -24,11 +24,11 @@
#ifndef __COGL_CONTEXT_H
#define __COGL_CONTEXT_H
#include "cogl-internal.h"
#include "cogl-context-driver.h"
#include "cogl-primitives.h"
#include "cogl-clip-stack.h"
#include "cogl-matrix-stack.h"
#include "cogl-current-matrix.h"
#include "cogl-material-private.h"
typedef struct
@ -58,7 +58,7 @@ typedef struct
gboolean indirect;
CoglMatrixMode matrix_mode;
/* Client-side matrix stack or NULL if none */
CoglMatrixMode flushed_matrix_mode;
CoglMatrixStack *projection_stack;
CoglMatrixStack *modelview_stack;

View File

@ -1,95 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/
#ifndef __COGL_CURRENT_MATRIX_H
#define __COGL_CURRENT_MATRIX_H
#include <cogl/cogl-matrix.h>
/**
* CoglMatrixMode:
* @COGL_MATRIX_MODELVIEW: Select model-view matrix stack
* @COGL_MATRIX_PROJECTION: Select projection matrix stack
* @COGL_MATRIX_TEXTURE: Select texture matrix stack
*
* There are several matrix stacks affected by the COGL current matrix
* operations (which are private). Code should always leave the
* model-view matrix active, switching to the projection matrix stack
* only temporarily in order to modify the projection matrix. Most
* COGL and Clutter APIs (other than the current matrix operations)
* will assume the model-view matrix is active when the API is
* invoked.
*
* Since: 1.0
*/
typedef enum
{
COGL_MATRIX_MODELVIEW = 1,
COGL_MATRIX_PROJECTION = 2,
COGL_MATRIX_TEXTURE = 3
} CoglMatrixMode;
#define COGL_TYPE_MATRIX_MODE (cogl_matrix_mode_get_type ())
GType cogl_matrix_mode_get_type (void) G_GNUC_CONST;
void _cogl_set_current_matrix (CoglMatrixMode mode);
void _cogl_current_matrix_push (void);
void _cogl_current_matrix_pop (void);
void _cogl_current_matrix_identity (void);
void _cogl_current_matrix_load (const CoglMatrix *matrix);
void _cogl_current_matrix_multiply (const CoglMatrix *matrix);
void _cogl_current_matrix_rotate (float angle,
float x,
float y,
float z);
void _cogl_current_matrix_scale (float x,
float y,
float z);
void _cogl_current_matrix_translate (float x,
float y,
float z);
void _cogl_current_matrix_frustum (float left,
float right,
float bottom,
float top,
float near_val,
float far_val);
void _cogl_current_matrix_ortho (float left,
float right,
float bottom,
float top,
float near_val,
float far_val);
void _cogl_get_matrix (CoglMatrixMode mode,
CoglMatrix *matrix);
void _cogl_current_matrix_state_init (void);
void _cogl_current_matrix_state_destroy (void);
void _cogl_current_matrix_state_flush (void);
void _cogl_current_matrix_state_dirty (void);
void _cogl_flush_matrix_stacks (void);
#endif /* __COGL_CURRENT_MATRIX_H */

View File

@ -24,9 +24,15 @@
#ifndef __COGL_INTERNAL_H
#define __COGL_INTERNAL_H
#include "cogl-debug.h"
#include "cogl-types.h"
#include "cogl-context.h"
#include "cogl.h"
#include "cogl-matrix-stack.h"
typedef enum
{
COGL_MATRIX_MODELVIEW,
COGL_MATRIX_PROJECTION,
COGL_MATRIX_TEXTURE
} CoglMatrixMode;
#ifdef HAVE_COGL_GLES2
typedef enum {
@ -97,4 +103,6 @@ _cogl_get_texture_unit (int index_);
void
_cogl_destroy_texture_units (void);
void _cogl_flush_matrix_stacks (void);
#endif /* __COGL_INTERNAL_H */

View File

@ -1179,6 +1179,8 @@ _cogl_material_layer_flush_gl_sampler_state (CoglMaterialLayer *layer,
int n_rgb_func_args;
int n_alpha_func_args;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
#ifndef DISABLE_MATERIAL_CACHE
if (!(gl_layer_info &&
gl_layer_info->flags & COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE &&

View File

@ -670,6 +670,8 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
GLint viewport[4];
CoglBitmap alpha_bmp;
CoglHandle prev_source;
CoglMatrixStack *projection_stack;
CoglMatrixStack *modelview_stack;
_COGL_GET_CONTEXT (ctx, FALSE);
@ -686,18 +688,16 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
* works)
*/
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_matrix_stack_ortho (ctx->projection_stack,
0, (float)(viewport[2]),
0, (float)(viewport[3]),
(float)(0),
(float)(100));
_cogl_current_matrix_ortho (0, (float)(viewport[2]),
0, (float)(viewport[3]),
(float)(0),
(float)(100));
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
/* Direct copy operation */
@ -778,10 +778,8 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
}
/* Restore old state */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (modelview_stack);
_cogl_matrix_stack_pop (projection_stack);
/* restore the original material */
cogl_set_source (prev_source);

View File

@ -33,7 +33,6 @@
#include "cogl-fixed.h"
#include "cogl-internal.h"
#include "cogl-material.h"
#include "cogl-current-matrix.h"
#include "cogl-offscreen.h"
#include "cogl-shader.h"
#include "cogl-texture.h"

View File

@ -334,20 +334,22 @@ set_clip_plane (GLint plane_num,
angle = atan2f (vertex_b[1] - vertex_a[1],
vertex_b[0] - vertex_a[0]) * (180.0/G_PI);
_cogl_current_matrix_push ();
_cogl_matrix_stack_push (ctx->modelview_stack);
/* Load the identity matrix and multiply by the reverse of the
projection matrix so we can specify the plane in screen
coordinates */
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
cogl_matrix_init_from_array (&inverse_projection,
ctx->inverse_projection);
_cogl_current_matrix_multiply (&inverse_projection);
_cogl_matrix_stack_multiply (ctx->modelview_stack, &inverse_projection);
/* Rotate about point a */
_cogl_current_matrix_translate (vertex_a[0], vertex_a[1], vertex_a[2]);
_cogl_matrix_stack_translate (ctx->modelview_stack,
vertex_a[0], vertex_a[1], vertex_a[2]);
/* Rotate the plane by the calculated angle so that it will connect
the two points */
_cogl_current_matrix_rotate (angle, 0.0f, 0.0f, 1.0f);
_cogl_current_matrix_translate (-vertex_a[0], -vertex_a[1], -vertex_a[2]);
_cogl_matrix_stack_rotate (ctx->modelview_stack, angle, 0.0f, 0.0f, 1.0f);
_cogl_matrix_stack_translate (ctx->modelview_stack,
-vertex_a[0], -vertex_a[1], -vertex_a[2]);
_cogl_flush_matrix_stacks ();
@ -361,7 +363,7 @@ set_clip_plane (GLint plane_num,
GE( glClipPlane (plane_num, plane) );
#endif
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->modelview_stack);
}
void
@ -373,16 +375,16 @@ _cogl_set_clip_planes (float x_offset,
CoglMatrix modelview_matrix;
CoglMatrix projection_matrix;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
float vertex_tl[4] = { x_offset, y_offset, 0, 1.0 };
float vertex_tr[4] = { x_offset + width, y_offset, 0, 1.0 };
float vertex_bl[4] = { x_offset, y_offset + height, 0, 1.0 };
float vertex_br[4] = { x_offset + width, y_offset + height,
0, 1.0 };
_cogl_get_matrix (COGL_MATRIX_PROJECTION,
&projection_matrix);
_cogl_get_matrix (COGL_MATRIX_MODELVIEW,
&modelview_matrix);
_cogl_matrix_stack_get (ctx->projection_stack, &projection_matrix);
_cogl_matrix_stack_get (ctx->modelview_stack, &modelview_matrix);
project_vertex (&modelview_matrix, &projection_matrix, vertex_tl);
project_vertex (&modelview_matrix, &projection_matrix, vertex_tr);
@ -423,6 +425,8 @@ _cogl_add_stencil_clip (float x_offset,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* We don't log changes to the stencil buffer so need to flush any
* batched geometry before we start... */
_cogl_journal_flush ();
/* temporarily swap in our special stenciling material */
@ -453,31 +457,25 @@ _cogl_add_stencil_clip (float x_offset,
cogl_rectangle (x_offset, y_offset,
x_offset + width, y_offset + height);
/* make sure our rectangle hits the stencil buffer before we
* change the stencil operation */
_cogl_journal_flush ();
/* Subtract one from all pixels in the stencil buffer so that
only pixels where both the original stencil buffer and the
rectangle are set will be valid */
GE( glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
/* Cogl generally assumes the modelview matrix is current, so since
* cogl_rectangle will be flushing GL state and emitting geometry
* to OpenGL it will be confused if we leave the projection matrix
* active... */
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_matrix_stack_pop (ctx->modelview_stack);
_cogl_matrix_stack_pop (ctx->projection_stack);
}
/* make sure our rectangles hit the stencil buffer before we restore
@ -543,10 +541,12 @@ _cogl_setup_viewport (guint width,
float z_camera;
CoglMatrix projection_matrix;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_viewport (width, height);
/* For Ortho projection.
* _cogl_current_matrix_ortho (0, width, 0, height, -1, 1);
* _cogl_matrix_stack_ortho (projection_stack, 0, width, 0, height, -1, 1);
*/
cogl_perspective (fovy, aspect, z_near, z_far);
@ -593,11 +593,12 @@ _cogl_setup_viewport (guint width,
cogl_get_projection_matrix (&projection_matrix);
z_camera = 0.5 * projection_matrix.xx;
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_identity ();
_cogl_current_matrix_translate (-0.5f, -0.5f, -z_camera);
_cogl_current_matrix_scale (1.0f / width, -1.0f / height, 1.0f / width);
_cogl_current_matrix_translate (0.0f, -1.0 * height, 0.0f);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
_cogl_matrix_stack_translate (ctx->modelview_stack, -0.5f, -0.5f, -z_camera);
_cogl_matrix_stack_scale (ctx->modelview_stack,
1.0f / width, -1.0f / height, 1.0f / width);
_cogl_matrix_stack_translate (ctx->modelview_stack,
0.0f, -1.0 * height, 0.0f);
}
CoglFeatureFlags
@ -936,3 +937,164 @@ _cogl_destroy_texture_units (void)
g_list_free (ctx->texture_units);
}
void
cogl_push_matrix (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_push (ctx->modelview_stack);
}
void
cogl_pop_matrix (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_pop (ctx->modelview_stack);
}
void
cogl_scale (float x, float y, float z)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_scale (ctx->modelview_stack, x, y, z);
}
void
cogl_translate (float x, float y, float z)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_translate (ctx->modelview_stack, x, y, z);
}
void
cogl_rotate (float angle, float x, float y, float z)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_rotate (ctx->modelview_stack, angle, x, y, z);
}
void
cogl_perspective (float fov_y,
float aspect,
float z_near,
float z_far)
{
float ymax = z_near * tanf (fov_y * G_PI / 360.0);
cogl_frustum (-ymax * aspect, /* left */
ymax * aspect, /* right */
-ymax, /* bottom */
ymax, /* top */
z_near,
z_far);
}
void
cogl_frustum (float left,
float right,
float bottom,
float top,
float z_near,
float z_far)
{
float c, d;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_matrix_stack_frustum (ctx->projection_stack,
left,
right,
bottom,
top,
z_near,
z_far);
/* Calculate and store the inverse of the matrix */
memset (ctx->inverse_projection, 0, sizeof (float) * 16);
c = - (z_far + z_near) / (z_far - z_near);
d = - (2 * (z_far * z_near)) / (z_far - z_near);
#define M(row,col) ctx->inverse_projection[col*4+row]
M(0,0) = (right - left) / (2 * z_near);
M(0,3) = (right + left) / (2 * z_near);
M(1,1) = (top - bottom) / (2 * z_near);
M(1,3) = (top + bottom) / (2 * z_near);
M(2,3) = -1.0;
M(3,2) = 1.0 / d;
M(3,3) = c / d;
#undef M
}
void
cogl_ortho (float left,
float right,
float bottom,
float top,
float z_near,
float z_far)
{
CoglMatrix ortho;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_matrix_init_identity (&ortho);
cogl_matrix_ortho (&ortho, left, right, bottom, top, z_near, z_far);
_cogl_matrix_stack_set (ctx->projection_stack, &ortho);
/* Calculate and store the inverse of the matrix */
memset (ctx->inverse_projection, 0, sizeof (float) * 16);
#define M(row,col) ctx->inverse_projection[col*4+row]
M(0,0) = 1.0 / ortho.xx;
M(0,3) = -ortho.xw;
M(1,1) = 1.0 / ortho.yy;
M(1,3) = -ortho.yw;
M(2,2) = 1.0 / ortho.zz;
M(2,3) = -ortho.zw;
M(3,3) = 1.0;
#undef M
}
void
cogl_get_modelview_matrix (CoglMatrix *matrix)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_get (ctx->modelview_stack, matrix);
}
void
cogl_set_modelview_matrix (CoglMatrix *matrix)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_set (ctx->modelview_stack, matrix);
}
void
cogl_get_projection_matrix (CoglMatrix *matrix)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_get (ctx->projection_stack, matrix);
}
void
cogl_set_projection_matrix (CoglMatrix *matrix)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_set (ctx->projection_stack, matrix);
/* FIXME: Update the inverse projection matrix!! Presumably use
* of clip planes must currently be broken if this API is used. */
}
void
_cogl_flush_matrix_stacks (void)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_matrix_stack_flush_to_gl (ctx->projection_stack,
COGL_MATRIX_PROJECTION);
_cogl_matrix_stack_flush_to_gl (ctx->modelview_stack,
COGL_MATRIX_MODELVIEW);
}

View File

@ -202,29 +202,25 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
from a non-screen buffer */
GE( glPushAttrib (GL_VIEWPORT_BIT) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
}
else
{
/* Override viewport and matrix setup if redirecting
from another offscreen buffer */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
}
/* Setup new viewport and matrices */
cogl_viewport (fbo->width, fbo->height);
_cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f);
_cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
_cogl_matrix_stack_translate (ctx->modelview_stack, -1.0f, -1.0f, 0.0f);
_cogl_matrix_stack_scale (ctx->modelview_stack, 2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
/* Bind offscreen framebuffer object */
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) );
@ -249,11 +245,9 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
from an offscreen buffer */
GE( glPopAttrib () );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->modelview_stack);
}
/* Bind window framebuffer object */

View File

@ -216,29 +216,19 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
/* Decrement all of the bits twice so that only pixels where the
value is 3 will remain */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
/* Cogl generally assumes the modelview matrix is current, so since
* cogl_rectangle will be flushing GL state and emitting geometry
* to OpenGL it will be confused if we leave the projection matrix
* active... */
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
_cogl_flush_matrix_stacks ();
glRectf (-1.0, -1.0, 1.0, 1.0);
glRectf (-1.0, -1.0, 1.0, 1.0);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_matrix_stack_pop (ctx->modelview_stack);
_cogl_matrix_stack_pop (ctx->projection_stack);
}
GE( glStencilMask (~(GLuint) 0) );

View File

@ -173,29 +173,26 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
from a non-screen buffer */
GE( glGetIntegerv (GL_VIEWPORT, ctx->drv.viewport_store) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
}
else
{
/* Override viewport and matrix setup if redirecting
from another offscreen buffer */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
}
/* Setup new viewport and matrices */
GE( glViewport (0, 0, fbo->width, fbo->height) );
_cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f);
_cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
_cogl_matrix_stack_translate (ctx->modelview_stack, -1.0f, -1.0f, 0.0f);
_cogl_matrix_stack_scale (ctx->modelview_stack,
2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
/* Bind offscreen framebuffer object */
GE( glBindFramebuffer (GL_FRAMEBUFFER, fbo->gl_handle) );
@ -229,11 +226,9 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
ctx->drv.viewport_store[2],
ctx->drv.viewport_store[3]) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->modelview_stack);
}
/* Bind window framebuffer object */

View File

@ -167,7 +167,7 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
GE( glColorMask (FALSE, FALSE, FALSE, FALSE) );
GE( glDepthMask (FALSE) );
_cogl_current_matrix_state_flush ();
_cogl_matrix_stack_flush_to_gl (ctx->modelview_stack, COGL_MATRIX_MODELVIEW);
while (path_start < path_size)
{
GE( glVertexPointer (2, GL_FLOAT, sizeof (CoglPathNode),
@ -204,27 +204,17 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
/* Decrement all of the bits twice so that only pixels where the
value is 3 will remain */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
/* Cogl generally assumes the modelview matrix is current, so since
* cogl_rectangle will be flushing GL state and emitting geometry
* to OpenGL it will be confused if we leave the projection matrix
* active... */
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_matrix_stack_pop (ctx->modelview_stack);
_cogl_matrix_stack_pop (ctx->projection_stack);
}
GE( glStencilMask (~(GLuint) 0) );

View File

@ -57,7 +57,6 @@ IGNORE_HFILES=\
cogl-defines-gles.h \
cogl-internal.h \
cogl-material-private.h \
cogl-current-matrix.h \
cogl-bitmap-private.h \
cogl-blend-string.h \
cogl-vertex-buffer-private.h \