4 * An object oriented GL/GLES Abstraction/Utility Layer
6 * Copyright (C) 2008,2009,2010 Intel Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see
20 * <http://www.gnu.org/licenses/>.
25 * Neil Roberts <neil@linux.intel.com>
32 #include "cogl-context-private.h"
33 #include "cogl-pipeline-private.h"
34 #include "cogl-pipeline-state-private.h"
35 #include "cogl-pipeline-opengl-private.h"
37 #ifdef COGL_PIPELINE_VERTEND_FIXED
39 #include "cogl-internal.h"
40 #include "cogl-context-private.h"
41 #include "cogl-handle.h"
42 #include "cogl-program-private.h"
44 const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
47 _cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
49 unsigned long pipelines_difference,
50 int n_tex_coord_attribs)
52 CoglProgram *user_program;
54 _COGL_GET_CONTEXT (ctx, FALSE);
56 if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
59 if (ctx->driver == COGL_DRIVER_GLES2)
62 /* Vertex snippets are only supported in the GLSL fragend */
63 if (_cogl_pipeline_has_vertex_snippets (pipeline))
66 /* If there is a user program with a vertex shader then the
67 appropriate backend for that language should handle it. We can
68 still use the fixed vertex backend if the program only contains
70 user_program = cogl_pipeline_get_user_program (pipeline);
71 if (user_program != COGL_INVALID_HANDLE &&
72 _cogl_program_has_vertex_shader (user_program))
75 _cogl_use_vertex_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
81 _cogl_pipeline_vertend_fixed_add_layer (CoglPipeline *pipeline,
82 CoglPipelineLayer *layer,
83 unsigned long layers_difference)
85 int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
86 CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index);
88 _COGL_GET_CONTEXT (ctx, FALSE);
90 if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX)
92 CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
93 CoglPipelineLayer *authority =
94 _cogl_pipeline_layer_get_authority (layer, state);
96 _cogl_matrix_stack_set (unit->matrix_stack,
97 &authority->big_state->matrix);
99 _cogl_set_active_texture_unit (unit_index);
101 _cogl_matrix_stack_flush_to_gl_builtins (ctx, unit->matrix_stack,
103 FALSE /* enable flip */);
110 _cogl_pipeline_vertend_fixed_end (CoglPipeline *pipeline,
111 unsigned long pipelines_difference)
113 _COGL_GET_CONTEXT (ctx, FALSE);
115 if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE)
117 CoglPipeline *authority =
118 _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE);
120 GE( ctx, glPointSize (authority->big_state->point_size) );
126 const CoglPipelineVertend _cogl_pipeline_fixed_vertend =
128 _cogl_pipeline_vertend_fixed_start,
129 _cogl_pipeline_vertend_fixed_add_layer,
130 _cogl_pipeline_vertend_fixed_end,
131 NULL, /* pipeline_change_notify */
132 NULL /* layer_change_notify */
135 #endif /* COGL_PIPELINE_VERTEND_FIXED */