summaryrefslogtreecommitdiff
path: root/cogl/deprecated/cogl-material-compat.c
blob: 25f97b1135d3b9c32f473abb2075a6aa3ca4a9c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
/*
 * Cogl
 *
 * A Low Level GPU Graphics and Utilities API
 *
 * Copyright (C) 2010 Intel Corporation.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * Authors:
 *  Robert Bragg <robert@linux.intel.com>
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <cogl-material-compat.h>
#include <cogl-pipeline.h>
#include <cogl-pipeline-private.h>
#include <cogl-types.h>
#include <cogl-matrix.h>
#include <cogl-context-private.h>

CoglMaterial *
cogl_material_new (void)
{
  _COGL_GET_CONTEXT(ctx, NULL);
  return COGL_MATERIAL (cogl_pipeline_new (ctx));
}

CoglMaterial *
cogl_material_copy (CoglMaterial *source)
{
  return COGL_MATERIAL (cogl_pipeline_copy (COGL_PIPELINE (source)));
}

CoglHandle
cogl_material_ref (CoglHandle handle)
{
  return cogl_object_ref (handle);
}

void
cogl_material_unref (CoglHandle handle)
{
  cogl_object_unref (handle);
}

CoglBool
cogl_is_material (CoglHandle handle)
{
  return cogl_is_pipeline (handle);
}

void
cogl_material_set_color (CoglMaterial    *material,
                         const CoglColor *color)
{
  cogl_pipeline_set_color (COGL_PIPELINE (material), color);
}

void
cogl_material_set_color4ub (CoglMaterial *material,
			    uint8_t red,
                            uint8_t green,
                            uint8_t blue,
                            uint8_t alpha)
{
  cogl_pipeline_set_color4ub (COGL_PIPELINE (material),
                              red, green, blue, alpha);
}

void
cogl_material_set_color4f (CoglMaterial *material,
                           float         red,
                           float         green,
                           float         blue,
                           float         alpha)
{
  cogl_pipeline_set_color4f (COGL_PIPELINE (material),
                             red, green, blue, alpha);
}

void
cogl_material_get_color (CoglMaterial *material,
                         CoglColor    *color)
{
  cogl_pipeline_get_color (COGL_PIPELINE (material), color);
}

void
cogl_material_set_ambient (CoglMaterial    *material,
			   const CoglColor *ambient)
{
  cogl_pipeline_set_ambient (COGL_PIPELINE (material), ambient);
}

void
cogl_material_get_ambient (CoglMaterial *material,
                           CoglColor    *ambient)
{
  cogl_pipeline_get_ambient (COGL_PIPELINE (material), ambient);
}

void
cogl_material_set_diffuse (CoglMaterial    *material,
			   const CoglColor *diffuse)
{
  cogl_pipeline_set_diffuse (COGL_PIPELINE (material), diffuse);
}

void
cogl_material_get_diffuse (CoglMaterial *material,
                           CoglColor    *diffuse)
{
  cogl_pipeline_get_diffuse (COGL_PIPELINE (material), diffuse);
}

void
cogl_material_set_ambient_and_diffuse (CoglMaterial    *material,
				       const CoglColor *color)
{
  cogl_pipeline_set_ambient_and_diffuse (COGL_PIPELINE (material), color);

}

void
cogl_material_set_specular (CoglMaterial    *material,
			    const CoglColor *specular)
{
  cogl_pipeline_set_specular (COGL_PIPELINE (material), specular);
}

void
cogl_material_get_specular (CoglMaterial *material,
                            CoglColor    *specular)
{
  cogl_pipeline_get_specular (COGL_PIPELINE (material), specular);
}

void
cogl_material_set_shininess (CoglMaterial *material,
			     float         shininess)
{
  cogl_pipeline_set_shininess (COGL_PIPELINE (material), shininess);
}

float
cogl_material_get_shininess (CoglMaterial *material)
{
  return cogl_pipeline_get_shininess (COGL_PIPELINE (material));
}

void
cogl_material_set_emission (CoglMaterial    *material,
			    const CoglColor *emission)
{
  cogl_pipeline_set_emission (COGL_PIPELINE (material), emission);

}

void
cogl_material_get_emission (CoglMaterial *material,
                            CoglColor    *emission)
{
  cogl_pipeline_get_emission (COGL_PIPELINE (material), emission);

}

void
cogl_material_set_alpha_test_function (CoglMaterial         *material,
				       CoglMaterialAlphaFunc alpha_func,
				       float                 alpha_reference)
{
  cogl_pipeline_set_alpha_test_function (COGL_PIPELINE (material),
                                         alpha_func,
                                         alpha_reference);
}

CoglBool
cogl_material_set_blend (CoglMaterial *material,
                         const char   *blend_string,
                         CoglError   **error)
{
  return cogl_pipeline_set_blend (COGL_PIPELINE (material),
                                  blend_string,
                                  error);
}

void
cogl_material_set_blend_constant (CoglMaterial *material,
                                  const CoglColor *constant_color)
{
  cogl_pipeline_set_blend_constant (COGL_PIPELINE (material), constant_color);
}

void
cogl_material_set_point_size (CoglMaterial *material,
                              float         point_size)
{
  cogl_pipeline_set_point_size (COGL_PIPELINE (material), point_size);
}

float
cogl_material_get_point_size (CoglMaterial *material)
{
  return cogl_pipeline_get_point_size (COGL_PIPELINE (material));
}

CoglHandle
cogl_material_get_user_program (CoglMaterial *material)
{
  return cogl_pipeline_get_user_program (COGL_PIPELINE (material));
}

void
cogl_material_set_user_program (CoglMaterial *material,
                                CoglHandle program)
{
  cogl_pipeline_set_user_program (COGL_PIPELINE (material), program);
}

void
cogl_material_set_layer (CoglMaterial *material,
			 int           layer_index,
			 CoglHandle    texture)
{
  cogl_pipeline_set_layer_texture (COGL_PIPELINE (material),
                                   layer_index, texture);
}

void
cogl_material_remove_layer (CoglMaterial *material,
			    int           layer_index)
{
  cogl_pipeline_remove_layer (COGL_PIPELINE (material), layer_index);
}

CoglBool
cogl_material_set_layer_combine (CoglMaterial *material,
				 int           layer_index,
				 const char   *blend_string,
                                 CoglError   **error)
{
  return cogl_pipeline_set_layer_combine (COGL_PIPELINE (material),
                                          layer_index,
                                          blend_string,
                                          error);
}

void
cogl_material_set_layer_combine_constant (CoglMaterial    *material,
                                          int              layer_index,
                                          const CoglColor *constant)
{
  cogl_pipeline_set_layer_combine_constant (COGL_PIPELINE (material),
                                            layer_index,
                                            constant);
}

void
cogl_material_set_layer_matrix (CoglMaterial     *material,
				int               layer_index,
				const CoglMatrix *matrix)
{
  cogl_pipeline_set_layer_matrix (COGL_PIPELINE (material),
                                  layer_index, matrix);
}

const GList *
cogl_material_get_layers (CoglMaterial *material)
{
  return _cogl_pipeline_get_layers (COGL_PIPELINE (material));
}

int
cogl_material_get_n_layers (CoglMaterial *material)
{
  return cogl_pipeline_get_n_layers (COGL_PIPELINE (material));
}

CoglMaterialLayerType
cogl_material_layer_get_type (CoglMaterialLayer *layer)
{
  return COGL_MATERIAL_LAYER_TYPE_TEXTURE;
}

CoglHandle
cogl_material_layer_get_texture (CoglMaterialLayer *layer)
{
  return _cogl_pipeline_layer_get_texture (COGL_PIPELINE_LAYER (layer));
}

CoglMaterialFilter
cogl_material_layer_get_min_filter (CoglMaterialLayer *layer)
{
  return _cogl_pipeline_layer_get_min_filter (COGL_PIPELINE_LAYER (layer));
}

CoglMaterialFilter
cogl_material_layer_get_mag_filter (CoglMaterialLayer *layer)
{
  return _cogl_pipeline_layer_get_mag_filter (COGL_PIPELINE_LAYER (layer));
}

void
cogl_material_set_layer_filters (CoglMaterial      *material,
                                 int                layer_index,
                                 CoglMaterialFilter min_filter,
                                 CoglMaterialFilter mag_filter)
{
  cogl_pipeline_set_layer_filters (COGL_PIPELINE (material),
                                   layer_index,
                                   min_filter,
                                   mag_filter);
}

CoglBool
cogl_material_set_layer_point_sprite_coords_enabled (CoglMaterial *material,
                                                     int           layer_index,
                                                     CoglBool      enable,
                                                     CoglError   **error)
{
  CoglPipeline *pipeline = COGL_PIPELINE (material);
  return cogl_pipeline_set_layer_point_sprite_coords_enabled (pipeline,
                                                              layer_index,
                                                              enable,
                                                              error);
}

CoglBool
cogl_material_get_layer_point_sprite_coords_enabled (CoglMaterial *material,
                                                     int           layer_index)
{
  CoglPipeline *pipeline = COGL_PIPELINE (material);
  return cogl_pipeline_get_layer_point_sprite_coords_enabled (pipeline,
                                                              layer_index);
}

CoglMaterialWrapMode
cogl_material_get_layer_wrap_mode_s (CoglMaterial *material,
                                     int           layer_index)
{
  return cogl_pipeline_get_layer_wrap_mode_s (COGL_PIPELINE (material),
                                              layer_index);
}

void
cogl_material_set_layer_wrap_mode_s (CoglMaterial        *material,
                                     int                  layer_index,
                                     CoglMaterialWrapMode mode)
{
  cogl_pipeline_set_layer_wrap_mode_s (COGL_PIPELINE (material), layer_index,
                                       mode);
}

CoglMaterialWrapMode
cogl_material_get_layer_wrap_mode_t (CoglMaterial *material,
                                     int           layer_index)
{
  return cogl_pipeline_get_layer_wrap_mode_t (COGL_PIPELINE (material),
                                              layer_index);
}

void
cogl_material_set_layer_wrap_mode_t (CoglMaterial        *material,
                                     int                  layer_index,
                                     CoglMaterialWrapMode mode)
{
  cogl_pipeline_set_layer_wrap_mode_t (COGL_PIPELINE (material), layer_index,
                                       mode);
}

CoglMaterialWrapMode
cogl_material_get_layer_wrap_mode_p (CoglMaterial *material,
                                     int           layer_index)
{
  return cogl_pipeline_get_layer_wrap_mode_p (COGL_PIPELINE (material),
                                              layer_index);
}

void
cogl_material_set_layer_wrap_mode_p (CoglMaterial        *material,
                                     int                  layer_index,
                                     CoglMaterialWrapMode mode)
{
  cogl_pipeline_set_layer_wrap_mode_p (COGL_PIPELINE (material), layer_index,
                                       mode);
}

void
cogl_material_set_layer_wrap_mode (CoglMaterial        *material,
                                   int                  layer_index,
                                   CoglMaterialWrapMode mode)
{
  cogl_pipeline_set_layer_wrap_mode (COGL_PIPELINE (material), layer_index,
                                     mode);
}

CoglMaterialWrapMode
cogl_material_layer_get_wrap_mode_s (CoglMaterialLayer *layer)
{
  return _cogl_pipeline_layer_get_wrap_mode_s (COGL_PIPELINE_LAYER (layer));
}

CoglMaterialWrapMode
cogl_material_layer_get_wrap_mode_t (CoglMaterialLayer *layer)
{
  return _cogl_pipeline_layer_get_wrap_mode_t (COGL_PIPELINE_LAYER (layer));
}

CoglMaterialWrapMode
cogl_material_layer_get_wrap_mode_p (CoglMaterialLayer *layer)
{
  return _cogl_pipeline_layer_get_wrap_mode_p (COGL_PIPELINE_LAYER (layer));
}

void
cogl_material_foreach_layer (CoglMaterial *material,
                             CoglMaterialLayerCallback callback,
                             void *user_data)
{
  cogl_pipeline_foreach_layer (COGL_PIPELINE (material),
                               (CoglPipelineLayerCallback)callback, user_data);
}

CoglBool
cogl_material_set_depth_state (CoglMaterial *material,
                               const CoglDepthState *state,
                               CoglError **error)
{
  return cogl_pipeline_set_depth_state (COGL_PIPELINE (material),
                                        state, error);
}

void
cogl_material_get_depth_state (CoglMaterial *material,
                               CoglDepthState *state_out)
{
  cogl_pipeline_get_depth_state (COGL_PIPELINE (material), state_out);
}