2 * Mesa 3-D graphics library
4 * Copyright (C) 1995-2006 Brian Paul
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * Library for glut using mesa fbdev driver
24 * Written by Sean D'Epagnier (c) 2006
33 #include "../../mesa/main/config.h"
37 int AccumSize
= 16; /* per channel size of accumulation buffer */
38 int DepthSize
= DEFAULT_SOFTWARE_DEPTH_BITS
;
39 int StencilSize
= STENCIL_BITS
;
42 int glutGet(GLenum state
)
49 case GLUT_INIT_WINDOW_WIDTH
:
50 case GLUT_WINDOW_WIDTH
:
51 case GLUT_SCREEN_WIDTH
:
53 case GLUT_INIT_WINDOW_HEIGHT
:
54 case GLUT_WINDOW_HEIGHT
:
55 case GLUT_SCREEN_HEIGHT
:
57 case GLUT_WINDOW_BUFFER_SIZE
:
58 return VarInfo
.bits_per_pixel
;
59 case GLUT_WINDOW_STENCIL_SIZE
:
61 case GLUT_WINDOW_DEPTH_SIZE
:
63 case GLUT_WINDOW_RED_SIZE
:
64 return VarInfo
.red
.length
;
65 case GLUT_WINDOW_GREEN_SIZE
:
66 return VarInfo
.green
.length
;
67 case GLUT_WINDOW_BLUE_SIZE
:
68 return VarInfo
.green
.length
;
69 case GLUT_WINDOW_ALPHA_SIZE
:
70 return VarInfo
.transp
.length
;
71 case GLUT_WINDOW_ACCUM_RED_SIZE
:
72 case GLUT_WINDOW_ACCUM_GREEN_SIZE
:
73 case GLUT_WINDOW_ACCUM_BLUE_SIZE
:
74 case GLUT_WINDOW_ACCUM_ALPHA_SIZE
:
76 case GLUT_WINDOW_DOUBLEBUFFER
:
77 if(DisplayMode
& GLUT_DOUBLE
)
80 case GLUT_WINDOW_RGBA
:
81 if(DisplayMode
& GLUT_INDEX
)
84 case GLUT_WINDOW_PARENT
:
86 case GLUT_WINDOW_NUM_CHILDREN
:
88 case GLUT_WINDOW_COLORMAP_SIZE
:
89 if(DisplayMode
& GLUT_INDEX
)
92 case GLUT_WINDOW_NUM_SAMPLES
:
94 case GLUT_WINDOW_STEREO
:
96 case GLUT_WINDOW_CURSOR
:
98 case GLUT_SCREEN_WIDTH_MM
:
100 case GLUT_SCREEN_HEIGHT_MM
:
101 return VarInfo
.height
;
102 case GLUT_MENU_NUM_ITEMS
:
104 return Menus
[CurrentMenu
].NumItems
;
106 case GLUT_DISPLAY_MODE_POSSIBLE
:
107 if((DisplayMode
& GLUT_MULTISAMPLE
)
108 || (DisplayMode
& GLUT_STEREO
)
109 || (DisplayMode
& GLUT_LUMINANCE
)
110 || (DisplayMode
& GLUT_ALPHA
) && (DisplayMode
& GLUT_INDEX
))
113 case GLUT_INIT_DISPLAY_MODE
:
115 case GLUT_INIT_WINDOW_X
:
116 case GLUT_INIT_WINDOW_Y
:
118 case GLUT_ELAPSED_TIME
:
120 static struct timeval tv
;
121 gettimeofday(&tv
, 0);
122 return 1000 * (tv
.tv_sec
- StartTime
.tv_sec
)
123 + (tv
.tv_usec
- StartTime
.tv_usec
) / 1000;
129 int glutLayerGet(GLenum info
)
132 case GLUT_OVERLAY_POSSIBLE
:
134 case GLUT_LAYER_IN_USE
:
136 case GLUT_HAS_OVERLAY
:
138 case GLUT_TRANSPARENT_INDEX
:
140 case GLUT_NORMAL_DAMAGED
:
142 case GLUT_OVERLAY_DAMAGED
:
148 int glutDeviceGet(GLenum info
)
151 case GLUT_HAS_KEYBOARD
:
152 return ConsoleFD
!= -1 ? 1 : 0;
154 case GLUT_NUM_MOUSE_BUTTONS
:
155 return NumMouseButtons
;
156 case GLUT_HAS_SPACEBALL
:
157 case GLUT_HAS_DIAL_AND_BUTTON_BOX
:
158 case GLUT_HAS_TABLET
:
160 case GLUT_NUM_SPACEBALL_BUTTONS
:
161 case GLUT_NUM_BUTTON_BOX_BUTTONS
:
163 case GLUT_NUM_TABLET_BUTTONS
:
165 case GLUT_DEVICE_IGNORE_KEY_REPEAT
:
166 return KeyRepeatMode
== GLUT_KEY_REPEAT_OFF
;
167 case GLUT_DEVICE_KEY_REPEAT
:
168 return KeyRepeatMode
;
169 case GLUT_JOYSTICK_POLL_RATE
:
170 case GLUT_HAS_JOYSTICK
:
171 case GLUT_JOYSTICK_BUTTONS
:
172 case GLUT_JOYSTICK_AXES
:
178 int glutGetModifiers(void){
179 return KeyboardModifiers
;
182 int glutExtensionSupported(const char *extension
)
184 const char *exts
= (const char *) glGetString(GL_EXTENSIONS
);
185 const char *start
= exts
;
186 int len
= strlen(extension
);
188 const char *p
= strstr(exts
, extension
);
191 if((p
== start
|| p
[-1] == ' ') && (p
[len
] == ' ' || p
[len
] == 0))