~ubuntu-branches/ubuntu/maverick/pyclutter/maverick

« back to all changes in this revision

Viewing changes to clutter/cogl-material.override

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort, Ross Burton, Luca Bruno, Emilio Pozuelo Monfort
  • Date: 2009-09-03 23:41:58 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090903234158-hpzhlkarkmykmnlj
Tags: 1.0.0-1
[ Ross Burton ]
* Bump libclutter-gtk-0.8-dev to 0.8.2 for pycluttergtk (Closes: #505918)
* Package the API documentation, add build-depends on xsltproc

[ Luca Bruno ]
* New upstream release.
* debian/TODO deleted.
* debian/control.in created and added pkg-gnome team to Uploaders.
* debian/rules:
  - Include uploaders.mk, gnome.mk and gnome-get-source.mk.
* debian/control:
  - Bump Standards-Version to 3.8.3, no changes needed.
  - Build-Depends:
    + Bump to libclutter-1.0-dev
    + Remove libclutter-gtk, libclutter-cairo, python-gst and libclutter-gst
      as bindings have been dropped upstream.
    + Remove python and python-dev.
    + Add gnome-pkg-tools.
  - Package python-clutter-dbg:
    + Section is debug.
    + Remove shlibs:Depends and python:Depends.
  - Add python-clutter-dev.
  - Add misc:Depends to python-clutter-doc.
  - Add Vcs-* fields.
  - Split Build-Depends on more lines.
* debian/examples:
  - Ship .png files. Closes: #473315
* debian/copyright:
  - Update download url to http://www.clutter-project.org/sources/pyclutter.
  - Update copyright holders according to upstream AUTHORS and README.

[ Emilio Pozuelo Monfort ]
* Add python-dev build dependency back, it's needed to build the package.
* Add homepage.
* Set python-clutter-dev to section python.
* Use different synopsis for python-clutter and python-clutter-dbg.
* debian/copyright: The license is LGPL 2.1, not 2.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
ignore
 
3
  cogl_is_material
 
4
%%
 
5
ignore-glob
 
6
  cogl_material_*
 
7
%%
 
8
body
 
9
/* COGL Material handle */
 
10
 
 
11
static PyObject *
 
12
pycogl_material_new (PyTypeObject *type, PyObject *args, PyObject *kwargs)
 
13
{
 
14
  return pycogl_handle_from_handle (cogl_material_new ());
 
15
}
 
16
 
 
17
static PyObject *
 
18
pycogl_material_set_color (PyCoglMaterial *self, PyObject *args)
 
19
{
 
20
  PyObject *py_color;
 
21
  CoglColor color;
 
22
 
 
23
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_color",
 
24
                         &py_color))
 
25
    return NULL;
 
26
 
 
27
  if (!pycogl_color_from_pyobject (py_color, &color))
 
28
    return NULL;
 
29
 
 
30
  cogl_material_set_color (self->handle, &color);
 
31
 
 
32
  Py_INCREF (Py_None);
 
33
  return Py_None;
 
34
}
 
35
 
 
36
static PyObject *
 
37
pycogl_material_get_color (PyCoglMaterial *self)
 
38
{
 
39
  CoglColor color;
 
40
  PyObject *py_ret;
 
41
 
 
42
  cogl_material_get_color (self->handle, &color);
 
43
  py_ret = pyobject_from_cogl_color (&color);
 
44
 
 
45
  return py_ret;
 
46
}
 
47
 
 
48
static PyObject *
 
49
pycogl_material_set_color4ub (PyCoglMaterial *self,
 
50
                              PyObject *args,
 
51
                              PyObject *kwargs)
 
52
{
 
53
  static char *kwlist[] = { "red", "green", "blue", "alpha", NULL };
 
54
  guint8 red, green, blue, alpha;
 
55
  red = green = blue = 0x0;
 
56
  alpha = 0xff;
 
57
 
 
58
  if (!PyArg_ParseTupleAndKeywords (args, kwargs,
 
59
                                    "|HHHH:cogl.Material.set_color4ub",
 
60
                                    kwlist,
 
61
                                    &red, &green, &blue, &alpha))
 
62
    return NULL;
 
63
 
 
64
  cogl_material_set_color4ub (self->handle, red, green, blue, alpha);
 
65
 
 
66
  Py_INCREF (Py_None);
 
67
  return Py_None;
 
68
}
 
69
 
 
70
static PyObject *
 
71
pycogl_material_set_color4f (PyCoglMaterial *self,
 
72
                             PyObject *args,
 
73
                             PyObject *kwargs)
 
74
{
 
75
  static char *kwlist[] = { "red", "green", "blue", "alpha", NULL };
 
76
  float red, green, blue, alpha;
 
77
  red = green = blue = 0.0;
 
78
  alpha = 1.0;
 
79
 
 
80
  if (!PyArg_ParseTupleAndKeywords (args, kwargs,
 
81
                                    "|ffff:cogl.Material.set_color4ub",
 
82
                                    kwlist,
 
83
                                    &red, &green, &blue, &alpha))
 
84
    return NULL;
 
85
 
 
86
  cogl_material_set_color4f (self->handle, red, green, blue, alpha);
 
87
 
 
88
  Py_INCREF (Py_None);
 
89
  return Py_None;
 
90
}
 
91
 
 
92
static PyObject *
 
93
pycogl_material_set_ambient (PyCoglMaterial *self, PyObject *args)
 
94
{
 
95
  PyObject *py_color;
 
96
  CoglColor color;
 
97
 
 
98
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_ambient",
 
99
                         &py_color))
 
100
    return NULL;
 
101
 
 
102
  if (!pycogl_color_from_pyobject (py_color, &color))
 
103
    return NULL;
 
104
 
 
105
  cogl_material_set_ambient (self->handle, &color);
 
106
 
 
107
  Py_INCREF (Py_None);
 
108
  return Py_None;
 
109
}
 
110
 
 
111
static PyObject *
 
112
pycogl_material_get_ambient (PyCoglMaterial *self)
 
113
{
 
114
  CoglColor color;
 
115
  PyObject *py_ret;
 
116
 
 
117
  cogl_material_get_ambient (self->handle, &color);
 
118
  py_ret = pyobject_from_cogl_color (&color);
 
119
 
 
120
  return py_ret;
 
121
}
 
122
 
 
123
static PyObject *
 
124
pycogl_material_set_diffuse (PyCoglMaterial *self, PyObject *args)
 
125
{
 
126
  PyObject *py_color;
 
127
  CoglColor color;
 
128
 
 
129
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_diffuse",
 
130
                         &py_color))
 
131
    return NULL;
 
132
 
 
133
  if (!pycogl_color_from_pyobject (py_color, &color))
 
134
    return NULL;
 
135
 
 
136
  cogl_material_set_diffuse (self->handle, &color);
 
137
 
 
138
  Py_INCREF (Py_None);
 
139
  return Py_None;
 
140
}
 
141
 
 
142
static PyObject *
 
143
pycogl_material_get_diffuse (PyCoglMaterial *self)
 
144
{
 
145
  CoglColor color;
 
146
  PyObject *py_ret;
 
147
 
 
148
  cogl_material_get_diffuse (self->handle, &color);
 
149
  py_ret = pyobject_from_cogl_color (&color);
 
150
 
 
151
  return py_ret;
 
152
}
 
153
 
 
154
static PyObject *
 
155
pycogl_material_set_ambient_and_diffuse (PyCoglMaterial *self, PyObject *args)
 
156
{
 
157
  PyObject *py_color;
 
158
  CoglColor color;
 
159
 
 
160
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_ambient",
 
161
                         &py_color))
 
162
    return NULL;
 
163
 
 
164
  if (!pycogl_color_from_pyobject (py_color, &color))
 
165
    return NULL;
 
166
 
 
167
  cogl_material_set_ambient_and_diffuse (self->handle, &color);
 
168
 
 
169
  Py_INCREF (Py_None);
 
170
  return Py_None;
 
171
}
 
172
 
 
173
static PyObject *
 
174
pycogl_material_set_emission (PyCoglMaterial *self, PyObject *args)
 
175
{
 
176
  PyObject *py_color;
 
177
  CoglColor color;
 
178
 
 
179
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_emission",
 
180
                         &py_color))
 
181
    return NULL;
 
182
 
 
183
  if (!pycogl_color_from_pyobject (py_color, &color))
 
184
    return NULL;
 
185
 
 
186
  cogl_material_set_emission (self->handle, &color);
 
187
 
 
188
  Py_INCREF (Py_None);
 
189
  return Py_None;
 
190
}
 
191
 
 
192
static PyObject *
 
193
pycogl_material_get_emission (PyCoglMaterial *self)
 
194
{
 
195
  CoglColor color;
 
196
  PyObject *py_ret;
 
197
 
 
198
  cogl_material_get_emission (self->handle, &color);
 
199
  py_ret = pyobject_from_cogl_color (&color);
 
200
 
 
201
  return py_ret;
 
202
}
 
203
 
 
204
static PyObject *
 
205
pycogl_material_set_specular (PyCoglMaterial *self, PyObject *args)
 
206
{
 
207
  PyObject *py_color;
 
208
  CoglColor color;
 
209
 
 
210
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_specular",
 
211
                         &py_color))
 
212
    return NULL;
 
213
 
 
214
  if (!pycogl_color_from_pyobject (py_color, &color))
 
215
    return NULL;
 
216
 
 
217
  cogl_material_set_specular (self->handle, &color);
 
218
 
 
219
  Py_INCREF (Py_None);
 
220
  return Py_None;
 
221
}
 
222
 
 
223
static PyObject *
 
224
pycogl_material_get_specular (PyCoglMaterial *self)
 
225
{
 
226
  CoglColor color;
 
227
  PyObject *py_ret;
 
228
 
 
229
  cogl_material_get_specular (self->handle, &color);
 
230
  py_ret = pyobject_from_cogl_color (&color);
 
231
 
 
232
  return py_ret;
 
233
}
 
234
 
 
235
static PyObject *
 
236
pycogl_material_set_shininess (PyCoglMaterial *self, PyObject *args)
 
237
{
 
238
  float shininess;
 
239
  if (!PyArg_ParseTuple (args, "f:cogl.Material.set_shininess",
 
240
                         &shininess))
 
241
    return NULL;
 
242
 
 
243
  cogl_material_set_shininess (self->handle, shininess);
 
244
 
 
245
  Py_INCREF (Py_None);
 
246
  return Py_None;
 
247
}
 
248
 
 
249
static PyObject *
 
250
pycogl_material_get_shininess (PyCoglMaterial *self)
 
251
{
 
252
  return Py_BuildValue ("f", cogl_material_get_shininess (self->handle));
 
253
}
 
254
 
 
255
static PyObject *
 
256
pycogl_material_set_alpha_test_function (PyCoglMaterial *self,
 
257
                                         PyObject       *args)
 
258
{
 
259
  PyObject *py_alpha_func;
 
260
  CoglMaterialAlphaFunc alpha_func;
 
261
  float alpha_reference;
 
262
 
 
263
  if (!PyArg_ParseTuple (args, "Of:cogl.Material.set_alpha_test_function",
 
264
                         &py_alpha_func, &alpha_reference))
 
265
    return NULL;
 
266
 
 
267
  if (pyg_enum_get_value (COGL_TYPE_MATERIAL_ALPHA_FUNC, py_alpha_func,
 
268
                          (gpointer)&alpha_func))
 
269
    return NULL;
 
270
 
 
271
  cogl_material_set_alpha_test_function (self->handle, alpha_func,
 
272
                                         alpha_reference);
 
273
 
 
274
  Py_INCREF (Py_None);
 
275
  return Py_None;
 
276
}
 
277
 
 
278
static PyObject *
 
279
pycogl_material_set_blend (PyCoglMaterial *self, PyObject *args)
 
280
{
 
281
  const char *blend_string;
 
282
  GError *error = NULL;
 
283
  gboolean ret;
 
284
 
 
285
  if (!PyArg_ParseTuple (args, "s:cogl.Material.set_blend",
 
286
                         &blend_string))
 
287
    return NULL;
 
288
 
 
289
  ret = cogl_material_set_blend (self->handle, blend_string, &error);
 
290
 
 
291
  if (!ret && error != NULL)
 
292
    {
 
293
      PyErr_Format (PyExc_RuntimeError, " %s", error->message);
 
294
      g_error_free (error);
 
295
      return NULL;
 
296
    }
 
297
 
 
298
  return PyBool_FromLong (ret);
 
299
}
 
300
 
 
301
static PyObject *
 
302
pycogl_material_set_blend_constant (PyCoglMaterial *self, PyObject *args)
 
303
{
 
304
  PyObject *py_color;
 
305
  CoglColor color;
 
306
 
 
307
  if (!PyArg_ParseTuple (args, "O:cogl.Material.set_blend_constant",
 
308
                         &py_color))
 
309
    return NULL;
 
310
 
 
311
  if (!pycogl_color_from_pyobject (py_color, &color))
 
312
    return NULL;
 
313
 
 
314
  cogl_material_set_blend_constant (self->handle, &color);
 
315
 
 
316
  Py_INCREF (Py_None);
 
317
  return Py_None;
 
318
}
 
319
 
 
320
static PyObject *
 
321
pycogl_material_set_layer (PyCoglMaterial *self, PyObject *args)
 
322
{
 
323
  int index;
 
324
  PyCoglTexture *texture;
 
325
 
 
326
  if (!PyArg_ParseTuple (args, "iO!:cogl.Material.set_layer",
 
327
                         &index, &PyCoglTexture_Type, &texture))
 
328
    return NULL;
 
329
 
 
330
  cogl_material_set_layer (self->handle, index, texture->handle);
 
331
 
 
332
  Py_INCREF (Py_None);
 
333
  return Py_None;
 
334
}
 
335
 
 
336
static PyObject *
 
337
pycogl_material_remove_layer (PyCoglMaterial *self, PyObject *args)
 
338
{
 
339
  int index;
 
340
 
 
341
  if (!PyArg_ParseTuple (args, "i:cogl.Material.remove_layer",
 
342
                         &index))
 
343
    return NULL;
 
344
 
 
345
  cogl_material_remove_layer (self->handle, index);
 
346
 
 
347
  Py_INCREF (Py_None);
 
348
  return Py_None;
 
349
}
 
350
 
 
351
static PyObject *
 
352
pycogl_material_set_layer_combine (PyCoglMaterial *self, PyObject *args)
 
353
{
 
354
  int index;
 
355
  const char *blend_string;
 
356
  GError *error = NULL;
 
357
  gboolean ret;
 
358
 
 
359
  if (!PyArg_ParseTuple (args, "is:cogl.Material.set_layer_combine",
 
360
                         &index, &blend_string))
 
361
    return NULL;
 
362
 
 
363
  ret = cogl_material_set_layer_combine (self->handle, index, blend_string,
 
364
                                         &error);
 
365
 
 
366
  if (!ret && error != NULL)
 
367
    {
 
368
      PyErr_Format (PyExc_RuntimeError, " %s", error->message);
 
369
      g_error_free (error);
 
370
      return NULL;
 
371
    }
 
372
 
 
373
  return PyBool_FromLong (ret);
 
374
}
 
375
 
 
376
static PyObject *
 
377
pycogl_material_set_layer_matrix (PyCoglMaterial *self, PyObject *args)
 
378
{
 
379
  int index;
 
380
  PyCoglMatrix *py_matrix;
 
381
 
 
382
  if (!PyArg_ParseTuple (args, "iO!:cogl.Material.set_layer_matrix",
 
383
                         &index, &PyCoglMatrix_Type, &py_matrix))
 
384
    return NULL;
 
385
 
 
386
  cogl_material_set_layer_matrix (self->handle, index, &py_matrix->matrix);
 
387
 
 
388
  Py_INCREF (Py_None);
 
389
  return Py_None;
 
390
}
 
391
 
 
392
static PyObject *
 
393
pycogl_material_get_layers (PyCoglMaterial *self)
 
394
{
 
395
  const GList *layers;
 
396
  GList *l;
 
397
  PyObject *py_list;
 
398
 
 
399
  layers = cogl_material_get_layers (self->handle);
 
400
 
 
401
  py_list = PyList_New (0);
 
402
 
 
403
  for (l = (GList *)layers; l != NULL; l = l->next)
 
404
    {
 
405
      PyObject *py_layer;
 
406
      CoglHandle handle = l->data;
 
407
 
 
408
      py_layer = pycogl_handle_from_handle (handle);
 
409
 
 
410
      if (!py_layer)
 
411
        {
 
412
          Py_DECREF (py_list);
 
413
          return NULL;
 
414
        }
 
415
 
 
416
      PyList_Append (py_list, py_layer);
 
417
    }
 
418
 
 
419
  return py_list;
 
420
}
 
421
 
 
422
static PyObject *
 
423
pycogl_material_get_n_layers (PyCoglMaterial *self)
 
424
{
 
425
  return Py_BuildValue ("i", cogl_material_get_n_layers (self->handle));
 
426
}
 
427
 
 
428
static PyObject *
 
429
pycogl_material_set_layer_filters (PyCoglMaterial *self, PyObject *args)
 
430
{
 
431
  gint layer_index;
 
432
  PyObject *py_min_filter, *py_mag_filter;
 
433
  CoglMaterialFilter min_filter, mag_filter;
 
434
 
 
435
  if (!PyArg_ParseTuple (args, "iOO:cogl.Material.set_layer_filters",
 
436
                         &layer_index, &py_min_filter, &py_mag_filter))
 
437
    return NULL;
 
438
 
 
439
  if (pyg_enum_get_value (COGL_TYPE_MATERIAL_FILTER, py_min_filter,
 
440
                          (gpointer)&min_filter))
 
441
    return NULL;
 
442
 
 
443
  if (pyg_enum_get_value (COGL_TYPE_MATERIAL_FILTER, py_mag_filter,
 
444
                          (gpointer)&mag_filter))
 
445
    return NULL;
 
446
 
 
447
  cogl_material_set_layer_filters (self->handle, layer_index,
 
448
                                   min_filter, mag_filter);
 
449
 
 
450
  Py_INCREF (Py_None);
 
451
  return Py_None;
 
452
}
 
453
 
 
454
 
 
455
static PyMethodDef pycogl_material_methods[] = {
 
456
    { "set_color", (PyCFunction)pycogl_material_set_color, METH_VARARGS },
 
457
    { "get_color", (PyCFunction)pycogl_material_get_color, METH_NOARGS },
 
458
    { "set_color4ub", (PyCFunction)pycogl_material_set_color4ub, METH_VARARGS|METH_KEYWORDS },
 
459
    { "set_color4f", (PyCFunction)pycogl_material_set_color4f, METH_VARARGS|METH_KEYWORDS },
 
460
    { "set_ambient", (PyCFunction)pycogl_material_set_ambient, METH_VARARGS },
 
461
    { "get_ambient", (PyCFunction)pycogl_material_get_ambient, METH_NOARGS },
 
462
    { "set_diffuse", (PyCFunction)pycogl_material_set_diffuse, METH_VARARGS },
 
463
    { "get_diffuse", (PyCFunction)pycogl_material_get_diffuse, METH_NOARGS },
 
464
    { "set_ambient_and_diffuse", (PyCFunction)pycogl_material_set_ambient_and_diffuse, METH_VARARGS },
 
465
    { "set_emission", (PyCFunction)pycogl_material_set_emission, METH_VARARGS },
 
466
    { "get_emission", (PyCFunction)pycogl_material_get_emission, METH_NOARGS },
 
467
    { "set_specular", (PyCFunction)pycogl_material_set_specular, METH_VARARGS },
 
468
    { "get_specular", (PyCFunction)pycogl_material_get_specular, METH_NOARGS },
 
469
    { "set_shininess", (PyCFunction)pycogl_material_set_shininess, METH_VARARGS },
 
470
    { "get_shininess", (PyCFunction)pycogl_material_get_shininess, METH_NOARGS },
 
471
    { "set_alpha_test_function", (PyCFunction)pycogl_material_set_alpha_test_function, METH_VARARGS },
 
472
    { "set_blend", (PyCFunction)pycogl_material_set_blend, METH_VARARGS },
 
473
    { "set_blend_constant", (PyCFunction)pycogl_material_set_blend_constant, METH_VARARGS },
 
474
    { "set_layer", (PyCFunction)pycogl_material_set_layer, METH_VARARGS },
 
475
    { "remove_layer", (PyCFunction)pycogl_material_remove_layer, METH_VARARGS },
 
476
    { "set_layer_combine", (PyCFunction)pycogl_material_set_layer_combine, METH_VARARGS },
 
477
    { "set_layer_matrix", (PyCFunction)pycogl_material_set_layer_matrix, METH_VARARGS },
 
478
    { "get_layers", (PyCFunction)pycogl_material_get_layers, METH_NOARGS },
 
479
    { "get_n_layers", (PyCFunction)pycogl_material_get_n_layers, METH_NOARGS },
 
480
    { "set_layer_filters", (PyCFunction)pycogl_material_set_layer_filters, METH_VARARGS },
 
481
    { NULL, NULL, 0, NULL },
 
482
};
 
483
 
 
484
PyTypeObject PyCoglMaterial_Type = {
 
485
    PyObject_HEAD_INIT(NULL)
 
486
    0,                                  /* ob_size */
 
487
    "cogl.Material",                    /* tp_name */
 
488
    sizeof(PyCoglMaterial),             /* tp_basicsize */
 
489
    0,                                  /* tp_itemsize */
 
490
    (destructor)pycogl_handle_dealloc,  /* tp_dealloc */
 
491
    0,                                  /* tp_print */
 
492
    0,                                  /* tp_getattr */
 
493
    0,                                  /* tp_setattr */
 
494
    0,                                  /* tp_compare */
 
495
    0,                                  /* tp_repr */
 
496
    0,                                  /* tp_as_number */
 
497
    0,                                  /* tp_as_sequence */
 
498
    0,                                  /* tp_as_mapping */
 
499
    0,                                  /* tp_hash */
 
500
    0,                                  /* tp_call */
 
501
    0,                                  /* tp_str */
 
502
    0,                                  /* tp_getattro */
 
503
    0,                                  /* tp_setattro */
 
504
    0,                                  /* tp_as_buffer */
 
505
    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
 
506
    0,                                  /* tp_doc */
 
507
    0,                                  /* tp_traverse */
 
508
    0,                                  /* tp_clear */
 
509
    0,                                  /* tp_richcompare */
 
510
    0,                                  /* tp_weaklistoffset */
 
511
    0,                                  /* tp_iter */
 
512
    0,                                  /* tp_iternext */
 
513
    pycogl_material_methods,            /* tp_methods */
 
514
    0,                                  /* tp_members */
 
515
    0,                                  /* tp_getset */
 
516
    0, /* &PyCoglHandle_Type, */        /* tp_base */
 
517
    0,                                  /* tp_dict */
 
518
    0,                                  /* tp_descr_get */
 
519
    0,                                  /* tp_descr_set */
 
520
    0,                                  /* tp_dictoffset */
 
521
    0,                                  /* tp_init */
 
522
    0,                                  /* tp_alloc */
 
523
    (newfunc)pycogl_material_new,       /* tp_new */
 
524
    0,                                  /* tp_free */
 
525
    0,                                  /* tp_is_gc */
 
526
    0,                                  /* tp_bases */
 
527
};
 
528
 
 
529