4 * Functions that didn't fit anywhere else...
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Thu Dec 9 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #define G_LOG_DOMAIN "freeglut-misc"
34 #include "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
38 * TODO BEFORE THE STABLE RELEASE:
42 * glutCopyColormap() --
43 * glutSetKeyRepeat() -- this is evil and should be removed from API
46 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
49 * This functions checks if an OpenGL extension is supported or not
51 int FGAPIENTRY glutExtensionSupported( const char* extension )
53 const char *extensions, *start;
55 const int len = strlen( extension ) ;
58 * Make sure there is a current window, and thus -- a current context available
60 freeglut_assert_ready;
61 freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
64 * Check if the extension itself looks valid (contains no spaces)
66 if (strchr(extension, ' '))
70 * Note it is safe to query the extensions
72 start = extensions = (const char *) glGetString(GL_EXTENSIONS);
74 /* XXX consider printing a warning to stderr that there's no current
77 freeglut_return_val_if_fail( extensions != NULL, 0 );
80 const char *p = strstr(extensions, extension);
82 return 0; /* not found */
83 /* check that the match isn't a super string */
84 if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
86 /* skip the false match and continue */
94 * This function reports all the OpenGL errors that happened till now
96 void FGAPIENTRY glutReportErrors( void )
98 GLenum error = glGetError();
101 * Keep reporting errors as long as there are any...
103 while( error != GL_NO_ERROR )
106 * Print the current error
109 # define G_LOG_DOMAIN ((gchar *) 0)
111 fgWarning( "GL error: %s", gluErrorString( error ) );
114 # define G_LOG_DOMAIN "freeglut_misc.c"
117 * Grab the next error value
119 error = glGetError();
124 * Turns the ignore key auto repeat feature on and off
126 void FGAPIENTRY glutIgnoreKeyRepeat( int ignore ) /* DEPRECATED 11/4/02 - Do not use */
129 * This is simple and not damaging...
131 fgState.IgnoreKeyRepeat = ignore ? TRUE : FALSE;
135 * Hints the window system whether to generate key auto repeat, or not. This is evil.
137 void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
139 #if TARGET_HOST_UNIX_X11
141 freeglut_assert_ready;
144 * This is really evil, but let's have this done.
148 case GLUT_KEY_REPEAT_OFF: XAutoRepeatOff( fgDisplay.Display ); break;
149 case GLUT_KEY_REPEAT_ON: XAutoRepeatOn( fgDisplay.Display ); break;
150 case GLUT_KEY_REPEAT_DEFAULT:
152 XKeyboardState keyboardState;
155 * Query the current keyboard state
157 XGetKeyboardControl( fgDisplay.Display, &keyboardState );
160 * Set the auto key repeat basing on the global settings
163 keyboardState.global_auto_repeat == AutoRepeatModeOn ?
164 GLUT_KEY_REPEAT_ON : GLUT_KEY_REPEAT_OFF
171 * Whoops, this was not expected at all
180 * Forces the joystick callback to be executed
182 void FGAPIENTRY glutForceJoystickFunc( void )
184 freeglut_assert_ready;
187 * Is there a current window selected?
189 freeglut_return_if_fail( fgStructure.Window != NULL );
192 * Check if there is a joystick callback hooked to the current window
194 freeglut_return_if_fail( fgStructure.Window->Callbacks.Joystick != NULL );
197 * Poll the joystick now, using the current window's joystick callback
199 fgJoystickPollWindow( fgStructure.Window );
205 void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue )
215 GLfloat FGAPIENTRY glutGetColor( int color, int component )
226 void FGAPIENTRY glutCopyColormap( int window )
233 /*** END OF FILE ***/