static CoglBool _cogl_pipeline_vertend_fixed_add_layer (CoglPipeline *pipeline, CoglPipelineLayer *layer, unsigned long layers_difference, CoglFramebuffer *framebuffer) { CoglContext *ctx = framebuffer->context; int unit_index = _cogl_pipeline_layer_get_unit_index (layer); CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index); if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX) { CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX; CoglPipelineLayer *authority = _cogl_pipeline_layer_get_authority (layer, state); CoglMatrixEntry *matrix_entry; cogl_matrix_stack_set (unit->matrix_stack, &authority->big_state->matrix); _cogl_set_active_texture_unit (unit_index); matrix_entry = unit->matrix_stack->last_entry; _cogl_matrix_entry_flush_to_gl_builtins (ctx, matrix_entry, COGL_MATRIX_TEXTURE, framebuffer, FALSE /* enable flip */); } return TRUE; }
static void _cogl_pipeline_progend_fixed_arbfp_pre_paint (CoglPipeline *pipeline, CoglFramebuffer *framebuffer) { CoglContext *ctx = framebuffer->context; if (ctx->current_projection_entry) _cogl_matrix_entry_flush_to_gl_builtins (ctx, ctx->current_projection_entry, COGL_MATRIX_PROJECTION, framebuffer, FALSE /* enable flip */); if (ctx->current_modelview_entry) _cogl_matrix_entry_flush_to_gl_builtins (ctx, ctx->current_modelview_entry, COGL_MATRIX_MODELVIEW, framebuffer, FALSE /* enable flip */); }
static void set_clip_plane (CoglFramebuffer *framebuffer, int plane_num, const float *vertex_a, const float *vertex_b) { CoglContext *ctx = framebuffer->context; float planef[4]; double planed[4]; float angle; CoglMatrixStack *modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer); CoglMatrixStack *projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer); CoglMatrix inverse_projection; cogl_matrix_stack_get_inverse (projection_stack, &inverse_projection); /* Calculate the angle between the axes and the line crossing the two points */ angle = atan2f (vertex_b[1] - vertex_a[1], vertex_b[0] - vertex_a[0]) * (180.0/G_PI); cogl_matrix_stack_push (modelview_stack); /* Load the inverse of the projection matrix so we can specify the plane * in screen coordinates */ cogl_matrix_stack_set (modelview_stack, &inverse_projection); /* Rotate about point a */ cogl_matrix_stack_translate (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_matrix_stack_rotate (modelview_stack, angle, 0.0f, 0.0f, 1.0f); cogl_matrix_stack_translate (modelview_stack, -vertex_a[0], -vertex_a[1], -vertex_a[2]); /* Clip planes can only be used when a fixed function backend is in use so we know we can directly push this matrix to the builtin state */ _cogl_matrix_entry_flush_to_gl_builtins (ctx, modelview_stack->last_entry, COGL_MATRIX_MODELVIEW, framebuffer, FALSE /* don't disable flip */); planef[0] = 0; planef[1] = -1.0; planef[2] = 0; planef[3] = vertex_a[1]; switch (ctx->driver) { default: g_assert_not_reached (); break; case COGL_DRIVER_GLES1: GE( ctx, glClipPlanef (plane_num, planef) ); break; case COGL_DRIVER_GL: case COGL_DRIVER_GL3: planed[0] = planef[0]; planed[1] = planef[1]; planed[2] = planef[2]; planed[3] = planef[3]; GE( ctx, glClipPlane (plane_num, planed) ); break; } cogl_matrix_stack_pop (modelview_stack); }