ba1a49adf2c2dddf7395e8f7187f782661307eb1
[mesa.git] / src / glut / directfb / init.c
1 /*
2 * Copyright (C) 2006 Claudio Ciccani <klan@users.sf.net>
3 *
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.
8 *
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.
13 *
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
17 *
18 */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "internal.h"
25
26
27 static void
28 __glutExit( void )
29 {
30 __glutFreeTimers();
31 __glutDestroyWindows();
32
33 if (events) {
34 events->Release( events );
35 events = NULL;
36 }
37
38 if (joystick) {
39 joystick->Release( joystick );
40 joystick = NULL;
41 }
42
43 if (mouse) {
44 mouse->Release( mouse );
45 mouse = NULL;
46 }
47
48 if (keyboard) {
49 keyboard->Release( keyboard );
50 keyboard = NULL;
51 }
52
53 if (primary) {
54 primary->Release( primary );
55 primary = NULL;
56 }
57
58 if (dfb) {
59 dfb->Release( dfb );
60 dfb = NULL;
61 }
62 }
63
64
65 void GLUTAPIENTRY
66 glutInit( int *argcp, char **argv )
67 {
68 DFBResult ret;
69
70 if (dfb)
71 return;
72
73 glutGet( GLUT_ELAPSED_TIME );
74
75 ret = DirectFBInit( argcp, argv ? &argv : NULL );
76 if (ret)
77 DirectFBErrorFatal( "DirectFBInit()", ret );
78
79 ret = DirectFBCreate( &dfb );
80 if (ret)
81 DirectFBErrorFatal( "DirectFBCreate()", ret );
82
83 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &primary );
84 if (ret)
85 DirectFBErrorFatal( "IDirectFB::GetDisplayLayer()", ret );
86
87 ret = dfb->CreateEventBuffer( dfb, &events );
88 if (ret)
89 DirectFBErrorFatal( "IDirectFB::CreateEventBuffer()", ret );
90
91 dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard );
92 dfb->GetInputDevice( dfb, DIDID_MOUSE, &mouse );
93 dfb->GetInputDevice( dfb, DIDID_JOYSTICK, &joystick );
94
95 primary->SetCooperativeLevel( primary, DLSCL_ADMINISTRATIVE );
96
97 atexit( __glutExit );
98 }
99
100
101 void GLUTAPIENTRY
102 glutInitDisplayMode( unsigned int mode )
103 {
104 g_display_mode = mode;
105 }
106
107
108 void GLUTAPIENTRY
109 glutInitWindowPosition( int x, int y )
110 {
111 g_xpos = x;
112 g_ypos = y;
113 }
114
115
116 void GLUTAPIENTRY
117 glutInitWindowSize( int width, int height )
118 {
119 g_width = width;
120 g_height = height;
121 }
122
123
124 void GLUTAPIENTRY
125 glutInitDisplayString( const char *string )
126 {
127 }
128