Debian Codegraph @

swig/gl.i

raw
1 /* File : gl.i */
2 //%module gl
3
4 %{
5 #ifndef FL_gl_H
6 #define FL_gl_H
7
8 void gl_start();
9 void gl_finish();
10
11 void gl_color(Fl_Color);
12 void gl_color(int c);
13
14 void gl_rect(int x,int y,int w,int h);
15 void gl_rectf(int x,int y,int w,int h);
16
17 void gl_font(int fontid, int size);
18 int gl_height();
19 int gl_descent();
20 double gl_width(const char *);
21 double gl_width(const char *, int n);
22 double gl_width(uchar);
23
24 void gl_draw(const char*);
25 void gl_draw(const char*, int n);
26 void gl_draw(const char*, int x, int y);
27 void gl_draw(const char*, float x, float y);
28 void gl_draw(const char*, int n, int x, int y);
29 void gl_draw(const char*, int n, float x, float y);
30 void gl_draw(const char*, int x, int y, int w, int h, Fl_Align);
31 void gl_measure(const char*, int& x, int& y);
32
33 void gl_draw_image(const uchar *, int x,int y,int w,int h, int d=3, int ld=0);
34
35 //from opengl for testing
36 void glLoadIdentity( void );
37 void glViewport( int x, int y, int width, int height );
38 void glClear( int mask );
39 void glColor3f( float red, float green, float blue );
40 void glBegin( int mode );
41 void glEnd( void );
42 void glVertex3f( float x, float y, float z );
43 #endif
44 %}
45
46 %ignore gl_color(Fl_Color);
47
48 %typemap(in) const uchar * {
49 /* Check if the input support the buffer protocol */
50 Py_buffer view;
51 const void * buffer;
52 int failure = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO);
53 if (!failure) {
54 // work with array object
55 buffer = view.buf;
56 PyBuffer_Release(&view);
57 $1 = (uchar *) buffer;
58 } else {
59 // work with list object
60 // clear the error from PyObject_GetBuffer
61 PyErr_Clear();
62 buffer=0;
63 /* Check if is a list */
64 if (PyList_Check($input)) {
65 Py_ssize_t size = PyList_Size($input);
66 int i = 0;
67 $1 = (uchar *) malloc((size+1)*sizeof(char));
68 for (i = 0; i < size; i++) {
69 PyObject *o = PyList_GetItem($input,i);
70 if (PyInt_Check(o))
71 $1[i] = (uchar)PyInt_AsLong(o);
72 else {
73 PyErr_SetString(PyExc_TypeError,"list must contain ints");
74 free($1);
75 return NULL;
76 }
77 }
78 $1[i] = 0;
79 } else {
80 PyErr_SetString(PyExc_TypeError,"not a list or does not support single-segment readable buffer interface");
81 return NULL;
82 }
83 }
84 }
85
86 %#ifndef DO_NOT_USE_OPENGL
87 %include "FL/gl.h"
88 %#else
89 %#define FL_gl_H
90 %#endif
91
92 %ignore gl_rectf;
93 %rename(gl_rectf) cond_gl_rectf;
94 void cond_gl_rectf(int x,int y,int w,int h)
95 {
96 %#ifdef DO_NOT_USE_OPENGL
97 fprintf(stderr, "Warning: gl_rectf not supported!\n");
98 %#else
99 glRecti(x,y,x+w,y+h);
100 %#endif
101 }
102
103 //from opengl for testing
104 void glLoadIdentity( void );
105 void glViewport( int x, int y, int width, int height );
106 void glClear( int mask );
107 void glColor3f( float red, float green, float blue );
108 void glBegin( int mode );
109 void glEnd( void );
110 void glVertex3f( float x, float y, float z );