2 * Copyright (C) 2006 Claudio Ciccani <klan@users.sf.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 glutSetCursor( int type
)
32 const unsigned char *cursor
;
33 DFBSurfaceDescription dsc
;
34 IDirectFBSurface
*shape
;
40 if (!g_current
|| !g_current
->window
)
43 if (g_current
->cursor
== type
)
47 case GLUT_CURSOR_RIGHT_ARROW
:
48 cursor
= &cur_right_arrow
[0];
50 case GLUT_CURSOR_LEFT_ARROW
:
51 cursor
= &cur_left_arrow
[0];
53 case GLUT_CURSOR_INFO
:
54 cursor
= &cur_info
[0];
56 case GLUT_CURSOR_DESTROY
:
57 cursor
= &cur_destroy
[0];
59 case GLUT_CURSOR_HELP
:
60 cursor
= &cur_help
[0];
62 case GLUT_CURSOR_CYCLE
:
63 cursor
= &cur_cycle
[0];
65 case GLUT_CURSOR_SPRAY
:
66 cursor
= &cur_spray
[0];
68 case GLUT_CURSOR_WAIT
:
69 cursor
= &cur_wait
[0];
71 case GLUT_CURSOR_TEXT
:
72 cursor
= &cur_text
[0];
74 case GLUT_CURSOR_CROSSHAIR
:
75 cursor
= &cur_crosshair
[0];
77 case GLUT_CURSOR_UP_DOWN
:
78 cursor
= &cur_up_down
[0];
80 case GLUT_CURSOR_LEFT_RIGHT
:
81 cursor
= &cur_left_right
[0];
83 case GLUT_CURSOR_TOP_SIDE
:
84 cursor
= &cur_top_side
[0];
86 case GLUT_CURSOR_BOTTOM_SIDE
:
87 cursor
= &cur_bottom_side
[0];
89 case GLUT_CURSOR_LEFT_SIDE
:
90 cursor
= &cur_left_side
[0];
92 case GLUT_CURSOR_RIGHT_SIDE
:
93 cursor
= &cur_right_side
[0];
95 case GLUT_CURSOR_TOP_LEFT_CORNER
:
96 cursor
= &cur_top_left
[0];
98 case GLUT_CURSOR_TOP_RIGHT_CORNER
:
99 cursor
= &cur_top_right
[0];
101 case GLUT_CURSOR_BOTTOM_RIGHT_CORNER
:
102 cursor
= &cur_bottom_right
[0];
104 case GLUT_CURSOR_BOTTOM_LEFT_CORNER
:
105 cursor
= &cur_bottom_left
[0];
108 cursor
= &cur_right_arrow
[0];
112 dsc
.flags
= DSDESC_WIDTH
| DSDESC_HEIGHT
| DSDESC_PIXELFORMAT
;
113 dsc
.width
= cursor
[0];
114 dsc
.height
= cursor
[0];
115 dsc
.pixelformat
= DSPF_ARGB
;
117 if (dfb
->CreateSurface( dfb
, &dsc
, &shape
))
120 if (shape
->Lock( shape
, DSLF_WRITE
, &dst
, &pitch
)) {
121 shape
->Release( shape
);
125 src
= (__u8
*) &cursor
[3];
126 msk
= src
+ cursor
[0]*cursor
[0]/8;
128 for (y
= 0; y
< cursor
[0]; y
++) {
129 for (x
= 0; x
< cursor
[0]; x
++) {
132 ((__u32
*)dst
)[x
] = ((src
[x
>>3] & (0x80 >> p
)) ? 0 : 0x00ffffff) |
133 ((msk
[x
>>3] & (0x80 >> p
)) ? 0xff000000 : 0);
141 shape
->Unlock( shape
);
143 g_current
->window
->SetCursorShape( g_current
->window
,
144 shape
, cursor
[1], cursor
[2] );
145 g_current
->cursor
= type
;
147 shape
->Release( shape
);
152 glutWarpPointer( int x
, int y
)
157 g_current
->window
->GetPosition( g_current
->window
, &wx
, &wy
);
158 primary
->WarpCursor( primary
, wx
+x
, wy
+y
);