2 * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that (i) the above copyright notices and this permission notice appear in
7 * all copies of the software and related documentation, and (ii) the name of
8 * Silicon Graphics may not be used in any advertising or
9 * publicity relating to the software without the specific, prior written
10 * permission of Silicon Graphics.
12 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
36 # include <OpenGL/glu.h>
37 # include <GLUT/glut.h>
48 * Identical to gluCheckExtension, which is not part of GLU on Windows.
51 checkExtension(const char *extName, const GLubyte *extString)
53 const char *p = (const char *)extString;
54 const char *q = extName;
58 if (c == '\0' || c == ' ') {
59 if (q && *q == '\0') {
76 static void checkGlError(const char *call) {
77 GLenum error = glGetError();
78 if (error != GL_NO_ERROR) {
79 fprintf(stderr, "error: %s -> %s\n", call, gluErrorString(error));
84 static void Init(void)
86 const GLubyte *extensions;
87 GLboolean has_GL_GREMEDY_string_marker;
88 GLboolean has_GL_GREMEDY_frame_terminator;
90 extensions = glGetString(GL_EXTENSIONS);
91 checkGlError("glGetString(GL_EXTENSIONS)");
92 has_GL_GREMEDY_string_marker = checkExtension("GL_GREMEDY_string_marker", extensions);
93 has_GL_GREMEDY_frame_terminator = checkExtension("GL_GREMEDY_string_marker", extensions);
95 if (GLEW_VERSION_3_0) {
96 GLint has_GL3_GREMEDY_string_marker = 0;
97 GLint has_GL3_GREMEDY_frame_terminator = 0;
100 GLint num_extensions = 0;
101 glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
102 checkGlError("glGetIntegerv(GL_NUM_EXTENSIONS)");
104 for (i = 0; i < num_extensions; ++i) {
105 const char *extension;
107 extension = (const char *)glGetStringi(GL_EXTENSIONS, i);
108 checkGlError("glGetStringi(GL_EXTENSIONS, i)");
110 if (strlen(extension) == 0) {
111 fprintf(stderr, "error: glGetStringi returned empty string\n");
115 if (strcmp(extension, "GL_GREMEDY_string_marker_count") == 0) {
116 ++has_GL3_GREMEDY_string_marker;
119 if (strcmp(extension, "GL_GREMEDY_frame_terminator") == 0) {
120 ++has_GL3_GREMEDY_frame_terminator;
124 if (!!has_GL_GREMEDY_string_marker != !!has_GL3_GREMEDY_string_marker) {
125 fprintf(stderr, "error: GL_GREMEDY_string_marker not consistently supported by GL3\n");
129 if (!!has_GL_GREMEDY_frame_terminator != !!has_GL3_GREMEDY_frame_terminator) {
130 fprintf(stderr, "error: GL_GREMEDY_frame_terminator not consistently supported by GL3\n");
137 if (!!has_GL_GREMEDY_string_marker != !!GLEW_GREMEDY_string_marker) {
138 fprintf(stderr, "error: GL_GREMEDY_string_marker not consistently supported by GLEW\n");
142 if (!!has_GL_GREMEDY_frame_terminator != !!GLEW_GREMEDY_frame_terminator) {
143 fprintf(stderr, "error: GL_GREMEDY_frame_terminator not consistently supported by GLEW\n");
147 if (GLEW_GREMEDY_string_marker) {
148 glStringMarkerGREMEDY(strlen("Init"), "Init - this should not be included");
151 glClearColor(0.3, 0.1, 0.3, 1.0);
154 static void Reshape(int width, int height)
156 if (GLEW_GREMEDY_string_marker) {
157 glStringMarkerGREMEDY(0, __FUNCTION__);
160 glViewport(0, 0, (GLint)width, (GLint)height);
162 glMatrixMode(GL_PROJECTION);
164 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
165 glMatrixMode(GL_MODELVIEW);
168 static void Draw(void)
170 if (GLEW_GREMEDY_string_marker) {
171 glStringMarkerGREMEDY(0, __FUNCTION__);
174 glClear(GL_COLOR_BUFFER_BIT);
176 glBegin(GL_TRIANGLES);
178 glVertex3f(-0.9, -0.9, -30.0);
180 glVertex3f( 0.9, -0.9, -30.0);
182 glVertex3f( 0.0, 0.9, -30.0);
187 if (GLEW_GREMEDY_frame_terminator) {
188 glFrameTerminatorGREMEDY();
191 glutDestroyWindow(win);
196 int main(int argc, char **argv)
198 glutInit(&argc, argv);
200 glutInitWindowSize(250, 250);
202 glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_SINGLE);
204 win = glutCreateWindow(*argv);
211 glutReshapeFunc(Reshape);
212 glutDisplayFunc(Draw);