Convert crlf->lf line endings.
[mesa.git] / src / glut / os2 / glut_ext.cpp
index feb6fbfa20b85117ce1074c29692b9a2f13327c9..6617fd6edb5e171fca74d3496113fe1c0bff2dfe 100644 (file)
-\r
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */\r
-\r
-/* This program is freely distributable without licensing fees\r
-   and is provided without guarantee or warrantee expressed or\r
-   implied. This program is -not- in the public domain. */\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include "glutint.h"\r
-\r
-/* CENTRY */\r
-int GLUTAPIENTRY\r
-glutExtensionSupported(const char *extension)\r
-{\r
-  static const GLubyte *extensions = NULL;\r
-  const GLubyte *start;\r
-  GLubyte *where, *terminator;\r
-\r
-  /* Extension names should not have spaces. */\r
-  where = (GLubyte *) strchr(extension, ' ');\r
-  if (where || *extension == '\0')\r
-    return 0;\r
-\r
-  if (!extensions) {\r
-    extensions = glGetString(GL_EXTENSIONS);\r
-  }\r
-  /* It takes a bit of care to be fool-proof about parsing the\r
-     OpenGL extensions string.  Don't be fooled by sub-strings,\r
-     etc. */\r
-  start = extensions;\r
-  for (;;) {\r
-    /* If your application crashes in the strstr routine below,\r
-       you are probably calling glutExtensionSupported without\r
-       having a current window.  Calling glGetString without\r
-       a current OpenGL context has unpredictable results.\r
-       Please fix your program. */\r
-    where = (GLubyte *) strstr((const char *) start, extension);\r
-    if (!where)\r
-      break;\r
-    terminator = where + strlen(extension);\r
-    if (where == start || *(where - 1) == ' ') {\r
-      if (*terminator == ' ' || *terminator == '\0') {\r
-        return 1;\r
-      }\r
-    }\r
-    start = terminator;\r
-  }\r
-  return 0;\r
-}\r
-\r
-\r
-struct name_address_pair {\r
-   const char *name;\r
-   const void *address;\r
-};\r
-\r
-static struct name_address_pair glut_functions[] = {\r
-   { "glutInit", (const void *) glutInit },\r
-   { "glutInitDisplayMode", (const void *) glutInitDisplayMode },\r
-   { "glutInitDisplayString", (const void *) glutInitDisplayString },\r
-   { "glutInitWindowPosition", (const void *) glutInitWindowPosition },\r
-   { "glutInitWindowSize", (const void *) glutInitWindowSize },\r
-   { "glutMainLoop", (const void *) glutMainLoop },\r
-   { "glutCreateWindow", (const void *) glutCreateWindow },\r
-   { "glutCreateSubWindow", (const void *) glutCreateSubWindow },\r
-   { "glutDestroyWindow", (const void *) glutDestroyWindow },\r
-   { "glutPostRedisplay", (const void *) glutPostRedisplay },\r
-   { "glutPostWindowRedisplay", (const void *) glutPostWindowRedisplay },\r
-   { "glutSwapBuffers", (const void *) glutSwapBuffers },\r
-   { "glutGetWindow", (const void *) glutGetWindow },\r
-   { "glutSetWindow", (const void *) glutSetWindow },\r
-   { "glutSetWindowTitle", (const void *) glutSetWindowTitle },\r
-   { "glutSetIconTitle", (const void *) glutSetIconTitle },\r
-   { "glutPositionWindow", (const void *) glutPositionWindow },\r
-   { "glutReshapeWindow", (const void *) glutReshapeWindow },\r
-   { "glutPopWindow", (const void *) glutPopWindow },\r
-   { "glutPushWindow", (const void *) glutPushWindow },\r
-   { "glutIconifyWindow", (const void *) glutIconifyWindow },\r
-   { "glutShowWindow", (const void *) glutShowWindow },\r
-   { "glutHideWindow", (const void *) glutHideWindow },\r
-   { "glutFullScreen", (const void *) glutFullScreen },\r
-   { "glutSetCursor", (const void *) glutSetCursor },\r
-   { "glutWarpPointer", (const void *) glutWarpPointer },\r
-   { "glutEstablishOverlay", (const void *) glutEstablishOverlay },\r
-   { "glutRemoveOverlay", (const void *) glutRemoveOverlay },\r
-   { "glutUseLayer", (const void *) glutUseLayer },\r
-   { "glutPostOverlayRedisplay", (const void *) glutPostOverlayRedisplay },\r
-   { "glutPostWindowOverlayRedisplay", (const void *) glutPostWindowOverlayRedisplay },\r
-   { "glutShowOverlay", (const void *) glutShowOverlay },\r
-   { "glutHideOverlay", (const void *) glutHideOverlay },\r
-   { "glutCreateMenu", (const void *) glutCreateMenu },\r
-   { "glutDestroyMenu", (const void *) glutDestroyMenu },\r
-   { "glutGetMenu", (const void *) glutGetMenu },\r
-   { "glutSetMenu", (const void *) glutSetMenu },\r
-   { "glutAddMenuEntry", (const void *) glutAddMenuEntry },\r
-   { "glutAddSubMenu", (const void *) glutAddSubMenu },\r
-   { "glutChangeToMenuEntry", (const void *) glutChangeToMenuEntry },\r
-   { "glutChangeToSubMenu", (const void *) glutChangeToSubMenu },\r
-   { "glutRemoveMenuItem", (const void *) glutRemoveMenuItem },\r
-   { "glutAttachMenu", (const void *) glutAttachMenu },\r
-   { "glutDetachMenu", (const void *) glutDetachMenu },\r
-   { "glutDisplayFunc", (const void *) glutDisplayFunc },\r
-   { "glutReshapeFunc", (const void *) glutReshapeFunc },\r
-   { "glutKeyboardFunc", (const void *) glutKeyboardFunc },\r
-   { "glutMouseFunc", (const void *) glutMouseFunc },\r
-   { "glutMotionFunc", (const void *) glutMotionFunc },\r
-   { "glutPassiveMotionFunc", (const void *) glutPassiveMotionFunc },\r
-   { "glutEntryFunc", (const void *) glutEntryFunc },\r
-   { "glutVisibilityFunc", (const void *) glutVisibilityFunc },\r
-   { "glutIdleFunc", (const void *) glutIdleFunc },\r
-   { "glutTimerFunc", (const void *) glutTimerFunc },\r
-   { "glutMenuStateFunc", (const void *) glutMenuStateFunc },\r
-   { "glutSpecialFunc", (const void *) glutSpecialFunc },\r
-   { "glutSpaceballMotionFunc", (const void *) glutSpaceballMotionFunc },\r
-   { "glutSpaceballRotateFunc", (const void *) glutSpaceballRotateFunc },\r
-   { "glutSpaceballButtonFunc", (const void *) glutSpaceballButtonFunc },\r
-   { "glutButtonBoxFunc", (const void *) glutButtonBoxFunc },\r
-   { "glutDialsFunc", (const void *) glutDialsFunc },\r
-   { "glutTabletMotionFunc", (const void *) glutTabletMotionFunc },\r
-   { "glutTabletButtonFunc", (const void *) glutTabletButtonFunc },\r
-   { "glutMenuStatusFunc", (const void *) glutMenuStatusFunc },\r
-   { "glutOverlayDisplayFunc", (const void *) glutOverlayDisplayFunc },\r
-   { "glutWindowStatusFunc", (const void *) glutWindowStatusFunc },\r
-   { "glutKeyboardUpFunc", (const void *) glutKeyboardUpFunc },\r
-   { "glutSpecialUpFunc", (const void *) glutSpecialUpFunc },\r
-   { "glutJoystickFunc", (const void *) glutJoystickFunc },\r
-   { "glutSetColor", (const void *) glutSetColor },\r
-   { "glutGetColor", (const void *) glutGetColor },\r
-   { "glutCopyColormap", (const void *) glutCopyColormap },\r
-   { "glutGet", (const void *) glutGet },\r
-   { "glutDeviceGet", (const void *) glutDeviceGet },\r
-   { "glutExtensionSupported", (const void *) glutExtensionSupported },\r
-   { "glutGetModifiers", (const void *) glutGetModifiers },\r
-   { "glutLayerGet", (const void *) glutLayerGet },\r
-   { "glutGetProcAddress", (const void *) glutGetProcAddress },\r
-   { "glutBitmapCharacter", (const void *) glutBitmapCharacter },\r
-   { "glutBitmapWidth", (const void *) glutBitmapWidth },\r
-   { "glutStrokeCharacter", (const void *) glutStrokeCharacter },\r
-   { "glutStrokeWidth", (const void *) glutStrokeWidth },\r
-   { "glutBitmapLength", (const void *) glutBitmapLength },\r
-   { "glutStrokeLength", (const void *) glutStrokeLength },\r
-   { "glutWireSphere", (const void *) glutWireSphere },\r
-   { "glutSolidSphere", (const void *) glutSolidSphere },\r
-   { "glutWireCone", (const void *) glutWireCone },\r
-   { "glutSolidCone", (const void *) glutSolidCone },\r
-   { "glutWireCube", (const void *) glutWireCube },\r
-   { "glutSolidCube", (const void *) glutSolidCube },\r
-   { "glutWireTorus", (const void *) glutWireTorus },\r
-   { "glutSolidTorus", (const void *) glutSolidTorus },\r
-   { "glutWireDodecahedron", (const void *) glutWireDodecahedron },\r
-   { "glutSolidDodecahedron", (const void *) glutSolidDodecahedron },\r
-   { "glutWireTeapot", (const void *) glutWireTeapot },\r
-   { "glutSolidTeapot", (const void *) glutSolidTeapot },\r
-   { "glutWireOctahedron", (const void *) glutWireOctahedron },\r
-   { "glutSolidOctahedron", (const void *) glutSolidOctahedron },\r
-   { "glutWireTetrahedron", (const void *) glutWireTetrahedron },\r
-   { "glutSolidTetrahedron", (const void *) glutSolidTetrahedron },\r
-   { "glutWireIcosahedron", (const void *) glutWireIcosahedron },\r
-   { "glutSolidIcosahedron", (const void *) glutSolidIcosahedron },\r
-   { "glutVideoResizeGet", (const void *) glutVideoResizeGet },\r
-   { "glutSetupVideoResizing", (const void *) glutSetupVideoResizing },\r
-   { "glutStopVideoResizing", (const void *) glutStopVideoResizing },\r
-   { "glutVideoResize", (const void *) glutVideoResize },\r
-   { "glutVideoPan", (const void *) glutVideoPan },\r
-   { "glutReportErrors", (const void *) glutReportErrors },\r
-   { "glutIgnoreKeyRepeat", (const void *) glutIgnoreKeyRepeat },\r
-   { "glutSetKeyRepeat", (const void *) glutSetKeyRepeat },\r
-   { "glutForceJoystickFunc", (const void *) glutForceJoystickFunc },\r
-   { "glutGameModeString", (const void *) glutGameModeString },\r
-   { "glutEnterGameMode", (const void *) glutEnterGameMode },\r
-   { "glutLeaveGameMode", (const void *) glutLeaveGameMode },\r
-   { "glutGameModeGet", (const void *) glutGameModeGet },\r
-   { NULL, NULL }\r
-};\r
-\r
-\r
-/* XXX This isn't an official GLUT function, yet */\r
-void * GLUTAPIENTRY\r
-glutGetProcAddress(const char *procName)\r
-{\r
-   /* Try GLUT functions first */\r
-   int i;\r
-   for (i = 0; glut_functions[i].name; i++) {\r
-      if (strcmp(glut_functions[i].name, procName) == 0)\r
-         return (void *) glut_functions[i].address;\r
-   }\r
-\r
-   /* Try core GL functions */\r
-#if defined(_WIN32)\r
-  return (void *) wglGetProcAddress((LPCSTR) procName);\r
-\r
-#elif  defined(__OS2PM__)\r
-  return (void *) wglGetProcAddress((char *) procName);\r
-#elif defined(GLX_ARB_get_proc_address)\r
-  return (void *) glXGetProcAddressARB((const GLubyte *) procName);\r
-#else\r
-  return NULL;\r
-#endif\r
-}\r
-\r
-\r
-/* ENDCENTRY */\r
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
+
+/* This program is freely distributable without licensing fees
+   and is provided without guarantee or warrantee expressed or
+   implied. This program is -not- in the public domain. */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "glutint.h"
+
+/* CENTRY */
+int GLUTAPIENTRY
+glutExtensionSupported(const char *extension)
+{
+  static const GLubyte *extensions = NULL;
+  const GLubyte *start;
+  GLubyte *where, *terminator;
+
+  /* Extension names should not have spaces. */
+  where = (GLubyte *) strchr(extension, ' ');
+  if (where || *extension == '\0')
+    return 0;
+
+  if (!extensions) {
+    extensions = glGetString(GL_EXTENSIONS);
+  }
+  /* It takes a bit of care to be fool-proof about parsing the
+     OpenGL extensions string.  Don't be fooled by sub-strings,
+     etc. */
+  start = extensions;
+  for (;;) {
+    /* If your application crashes in the strstr routine below,
+       you are probably calling glutExtensionSupported without
+       having a current window.  Calling glGetString without
+       a current OpenGL context has unpredictable results.
+       Please fix your program. */
+    where = (GLubyte *) strstr((const char *) start, extension);
+    if (!where)
+      break;
+    terminator = where + strlen(extension);
+    if (where == start || *(where - 1) == ' ') {
+      if (*terminator == ' ' || *terminator == '\0') {
+        return 1;
+      }
+    }
+    start = terminator;
+  }
+  return 0;
+}
+
+
+struct name_address_pair {
+   const char *name;
+   const void *address;
+};
+
+static struct name_address_pair glut_functions[] = {
+   { "glutInit", (const void *) glutInit },
+   { "glutInitDisplayMode", (const void *) glutInitDisplayMode },
+   { "glutInitDisplayString", (const void *) glutInitDisplayString },
+   { "glutInitWindowPosition", (const void *) glutInitWindowPosition },
+   { "glutInitWindowSize", (const void *) glutInitWindowSize },
+   { "glutMainLoop", (const void *) glutMainLoop },
+   { "glutCreateWindow", (const void *) glutCreateWindow },
+   { "glutCreateSubWindow", (const void *) glutCreateSubWindow },
+   { "glutDestroyWindow", (const void *) glutDestroyWindow },
+   { "glutPostRedisplay", (const void *) glutPostRedisplay },
+   { "glutPostWindowRedisplay", (const void *) glutPostWindowRedisplay },
+   { "glutSwapBuffers", (const void *) glutSwapBuffers },
+   { "glutGetWindow", (const void *) glutGetWindow },
+   { "glutSetWindow", (const void *) glutSetWindow },
+   { "glutSetWindowTitle", (const void *) glutSetWindowTitle },
+   { "glutSetIconTitle", (const void *) glutSetIconTitle },
+   { "glutPositionWindow", (const void *) glutPositionWindow },
+   { "glutReshapeWindow", (const void *) glutReshapeWindow },
+   { "glutPopWindow", (const void *) glutPopWindow },
+   { "glutPushWindow", (const void *) glutPushWindow },
+   { "glutIconifyWindow", (const void *) glutIconifyWindow },
+   { "glutShowWindow", (const void *) glutShowWindow },
+   { "glutHideWindow", (const void *) glutHideWindow },
+   { "glutFullScreen", (const void *) glutFullScreen },
+   { "glutSetCursor", (const void *) glutSetCursor },
+   { "glutWarpPointer", (const void *) glutWarpPointer },
+   { "glutEstablishOverlay", (const void *) glutEstablishOverlay },
+   { "glutRemoveOverlay", (const void *) glutRemoveOverlay },
+   { "glutUseLayer", (const void *) glutUseLayer },
+   { "glutPostOverlayRedisplay", (const void *) glutPostOverlayRedisplay },
+   { "glutPostWindowOverlayRedisplay", (const void *) glutPostWindowOverlayRedisplay },
+   { "glutShowOverlay", (const void *) glutShowOverlay },
+   { "glutHideOverlay", (const void *) glutHideOverlay },
+   { "glutCreateMenu", (const void *) glutCreateMenu },
+   { "glutDestroyMenu", (const void *) glutDestroyMenu },
+   { "glutGetMenu", (const void *) glutGetMenu },
+   { "glutSetMenu", (const void *) glutSetMenu },
+   { "glutAddMenuEntry", (const void *) glutAddMenuEntry },
+   { "glutAddSubMenu", (const void *) glutAddSubMenu },
+   { "glutChangeToMenuEntry", (const void *) glutChangeToMenuEntry },
+   { "glutChangeToSubMenu", (const void *) glutChangeToSubMenu },
+   { "glutRemoveMenuItem", (const void *) glutRemoveMenuItem },
+   { "glutAttachMenu", (const void *) glutAttachMenu },
+   { "glutDetachMenu", (const void *) glutDetachMenu },
+   { "glutDisplayFunc", (const void *) glutDisplayFunc },
+   { "glutReshapeFunc", (const void *) glutReshapeFunc },
+   { "glutKeyboardFunc", (const void *) glutKeyboardFunc },
+   { "glutMouseFunc", (const void *) glutMouseFunc },
+   { "glutMotionFunc", (const void *) glutMotionFunc },
+   { "glutPassiveMotionFunc", (const void *) glutPassiveMotionFunc },
+   { "glutEntryFunc", (const void *) glutEntryFunc },
+   { "glutVisibilityFunc", (const void *) glutVisibilityFunc },
+   { "glutIdleFunc", (const void *) glutIdleFunc },
+   { "glutTimerFunc", (const void *) glutTimerFunc },
+   { "glutMenuStateFunc", (const void *) glutMenuStateFunc },
+   { "glutSpecialFunc", (const void *) glutSpecialFunc },
+   { "glutSpaceballMotionFunc", (const void *) glutSpaceballMotionFunc },
+   { "glutSpaceballRotateFunc", (const void *) glutSpaceballRotateFunc },
+   { "glutSpaceballButtonFunc", (const void *) glutSpaceballButtonFunc },
+   { "glutButtonBoxFunc", (const void *) glutButtonBoxFunc },
+   { "glutDialsFunc", (const void *) glutDialsFunc },
+   { "glutTabletMotionFunc", (const void *) glutTabletMotionFunc },
+   { "glutTabletButtonFunc", (const void *) glutTabletButtonFunc },
+   { "glutMenuStatusFunc", (const void *) glutMenuStatusFunc },
+   { "glutOverlayDisplayFunc", (const void *) glutOverlayDisplayFunc },
+   { "glutWindowStatusFunc", (const void *) glutWindowStatusFunc },
+   { "glutKeyboardUpFunc", (const void *) glutKeyboardUpFunc },
+   { "glutSpecialUpFunc", (const void *) glutSpecialUpFunc },
+   { "glutJoystickFunc", (const void *) glutJoystickFunc },
+   { "glutSetColor", (const void *) glutSetColor },
+   { "glutGetColor", (const void *) glutGetColor },
+   { "glutCopyColormap", (const void *) glutCopyColormap },
+   { "glutGet", (const void *) glutGet },
+   { "glutDeviceGet", (const void *) glutDeviceGet },
+   { "glutExtensionSupported", (const void *) glutExtensionSupported },
+   { "glutGetModifiers", (const void *) glutGetModifiers },
+   { "glutLayerGet", (const void *) glutLayerGet },
+   { "glutGetProcAddress", (const void *) glutGetProcAddress },
+   { "glutBitmapCharacter", (const void *) glutBitmapCharacter },
+   { "glutBitmapWidth", (const void *) glutBitmapWidth },
+   { "glutStrokeCharacter", (const void *) glutStrokeCharacter },
+   { "glutStrokeWidth", (const void *) glutStrokeWidth },
+   { "glutBitmapLength", (const void *) glutBitmapLength },
+   { "glutStrokeLength", (const void *) glutStrokeLength },
+   { "glutWireSphere", (const void *) glutWireSphere },
+   { "glutSolidSphere", (const void *) glutSolidSphere },
+   { "glutWireCone", (const void *) glutWireCone },
+   { "glutSolidCone", (const void *) glutSolidCone },
+   { "glutWireCube", (const void *) glutWireCube },
+   { "glutSolidCube", (const void *) glutSolidCube },
+   { "glutWireTorus", (const void *) glutWireTorus },
+   { "glutSolidTorus", (const void *) glutSolidTorus },
+   { "glutWireDodecahedron", (const void *) glutWireDodecahedron },
+   { "glutSolidDodecahedron", (const void *) glutSolidDodecahedron },
+   { "glutWireTeapot", (const void *) glutWireTeapot },
+   { "glutSolidTeapot", (const void *) glutSolidTeapot },
+   { "glutWireOctahedron", (const void *) glutWireOctahedron },
+   { "glutSolidOctahedron", (const void *) glutSolidOctahedron },
+   { "glutWireTetrahedron", (const void *) glutWireTetrahedron },
+   { "glutSolidTetrahedron", (const void *) glutSolidTetrahedron },
+   { "glutWireIcosahedron", (const void *) glutWireIcosahedron },
+   { "glutSolidIcosahedron", (const void *) glutSolidIcosahedron },
+   { "glutVideoResizeGet", (const void *) glutVideoResizeGet },
+   { "glutSetupVideoResizing", (const void *) glutSetupVideoResizing },
+   { "glutStopVideoResizing", (const void *) glutStopVideoResizing },
+   { "glutVideoResize", (const void *) glutVideoResize },
+   { "glutVideoPan", (const void *) glutVideoPan },
+   { "glutReportErrors", (const void *) glutReportErrors },
+   { "glutIgnoreKeyRepeat", (const void *) glutIgnoreKeyRepeat },
+   { "glutSetKeyRepeat", (const void *) glutSetKeyRepeat },
+   { "glutForceJoystickFunc", (const void *) glutForceJoystickFunc },
+   { "glutGameModeString", (const void *) glutGameModeString },
+   { "glutEnterGameMode", (const void *) glutEnterGameMode },
+   { "glutLeaveGameMode", (const void *) glutLeaveGameMode },
+   { "glutGameModeGet", (const void *) glutGameModeGet },
+   { NULL, NULL }
+};
+
+
+/* XXX This isn't an official GLUT function, yet */
+void * GLUTAPIENTRY
+glutGetProcAddress(const char *procName)
+{
+   /* Try GLUT functions first */
+   int i;
+   for (i = 0; glut_functions[i].name; i++) {
+      if (strcmp(glut_functions[i].name, procName) == 0)
+         return (void *) glut_functions[i].address;
+   }
+
+   /* Try core GL functions */
+#if defined(_WIN32)
+  return (void *) wglGetProcAddress((LPCSTR) procName);
+
+#elif  defined(__OS2PM__)
+  return (void *) wglGetProcAddress((char *) procName);
+#elif defined(GLX_ARB_get_proc_address)
+  return (void *) glXGetProcAddressARB((const GLubyte *) procName);
+#else
+  return NULL;
+#endif
+}
+
+
+/* ENDCENTRY */