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.
28 #include <GL/freeglut.h>
29 #include "fg_internal.h"
32 * TODO BEFORE THE STABLE RELEASE:
36 * glutCopyColormap() --
37 * glutSetKeyRepeat() -- this is evil and should be removed from API
40 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
43 * This functions checks if an OpenGL extension is supported or not
45 * XXX Wouldn't this be simpler and clearer if we used strtok()?
47 int FGAPIENTRY glutExtensionSupported( const char* extension )
49 const char *extensions, *start;
50 const size_t len = strlen( extension );
52 /* Make sure there is a current window, and thus a current context available */
53 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutExtensionSupported" );
54 freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
56 if (strchr(extension, ' '))
58 start = extensions = (const char *) glGetString(GL_EXTENSIONS);
60 /* XXX consider printing a warning to stderr that there's no current
63 freeglut_return_val_if_fail( extensions != NULL, 0 );
66 const char *p = strstr(extensions, extension);
68 return 0; /* not found */
69 /* check that the match isn't a super string */
70 if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
72 /* skip the false match and continue */
79 #ifndef GL_INVALID_FRAMEBUFFER_OPERATION
80 #ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
81 #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
83 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
87 #ifndef GL_TABLE_TOO_LARGE
88 #ifdef GL_TABLE_TOO_LARGE_EXT
89 #define GL_TABLE_TOO_LARGE GL_TABLE_TOO_LARGE_EXT
91 #define GL_TABLE_TOO_LARGE 0x8031
95 #ifndef GL_TEXTURE_TOO_LARGE
96 #ifdef GL_TEXTURE_TOO_LARGE_EXT
97 #define GL_TEXTURE_TOO_LARGE GL_TEXTURE_TOO_LARGE_EXT
99 #define GL_TEXTURE_TOO_LARGE 0x8065
104 * A cut-down local version of gluErrorString to avoid depending on GLU.
106 static const char* fghErrorString( GLenum error )
109 case GL_INVALID_ENUM: return "invalid enumerant";
110 case GL_INVALID_VALUE: return "invalid value";
111 case GL_INVALID_OPERATION: return "invalid operation";
112 #ifndef GL_ES_VERSION_2_0
113 case GL_STACK_OVERFLOW: return "stack overflow";
114 case GL_STACK_UNDERFLOW: return "stack underflow";
116 case GL_OUT_OF_MEMORY: return "out of memory";
117 case GL_TABLE_TOO_LARGE: return "table too large";
118 case GL_INVALID_FRAMEBUFFER_OPERATION: return "invalid framebuffer operation";
119 case GL_TEXTURE_TOO_LARGE: return "texture too large";
120 default: return "unknown GL error";
125 * This function reports all the OpenGL errors that happened till now
127 void FGAPIENTRY glutReportErrors( void )
130 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReportErrors" );
131 while( ( error = glGetError() ) != GL_NO_ERROR )
132 fgWarning( "GL error: %s", fghErrorString( error ) );
136 * Control the auto-repeat of keystrokes to the current window
138 void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
140 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIgnoreKeyRepeat" );
141 FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" );
143 fgStructure.CurrentWindow->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE;
147 * Set global auto-repeat of keystrokes
149 * RepeatMode should be any of:
150 * GLUT_KEY_REPEAT_OFF
152 * GLUT_KEY_REPEAT_DEFAULT
154 void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
156 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetKeyRepeat" );
160 case GLUT_KEY_REPEAT_OFF:
161 fgState.KeyRepeat = GLUT_KEY_REPEAT_OFF;
164 case GLUT_KEY_REPEAT_ON:
165 case GLUT_KEY_REPEAT_DEFAULT:
166 fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
170 fgError ("Invalid glutSetKeyRepeat mode: %d", repeatMode);
178 void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue )
180 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetColor" );
181 /* We really need to do something here. */
187 GLfloat FGAPIENTRY glutGetColor( int color, int component )
189 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetColor" );
190 /* We really need to do something here. */
197 void FGAPIENTRY glutCopyColormap( int window )
199 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCopyColormap" );
200 /* We really need to do something here. */
203 /*** END OF FILE ***/