2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2003-09-26 13:49:28 +00:00
|
|
|
int main ()
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
|
|
|
GLuint err;
|
2003-09-26 13:49:28 +00:00
|
|
|
if (GL_TRUE == glewCreateContext())
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error: glewCreateContext failed\n");
|
|
|
|
glewDestroyContext();
|
|
|
|
return 1;
|
|
|
|
}
|
2003-07-06 15:01:13 +00:00
|
|
|
glewExperimental = GL_TRUE;
|
|
|
|
err = glewInit();
|
|
|
|
if (GLEW_OK != err)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
|
2003-09-26 13:49:28 +00:00
|
|
|
glewDestroyContext();
|
2003-07-06 15:01:13 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2003-07-06 20:03:33 +00:00
|
|
|
#ifdef _WIN32
|
2003-07-06 15:01:13 +00:00
|
|
|
f = fopen("glewinfo.txt", "w");
|
|
|
|
if (f == NULL) f = stdout;
|
2003-07-06 20:03:33 +00:00
|
|
|
#else
|
|
|
|
f = stdout;
|
|
|
|
#endif
|
2003-07-06 15:01:13 +00:00
|
|
|
fprintf(f, "---------------------------\n");
|
|
|
|
fprintf(f, " GLEW Extension Info\n");
|
|
|
|
fprintf(f, "---------------------------\n\n");
|
|
|
|
fprintf(f, "Running on a %s from %s\n",
|
|
|
|
glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
|
|
|
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
|
2003-09-12 03:50:22 +00:00
|
|
|
fprintf(f, "GLEW version %s is supported\n", glewGetString(GLEW_VERSION));
|
2003-07-06 15:01:13 +00:00
|
|
|
glewInfo();
|
|
|
|
#ifdef _WIN32
|
|
|
|
wglewInfo();
|
|
|
|
#else
|
|
|
|
glxewInfo();
|
|
|
|
#endif
|
|
|
|
if (f != stdout) fclose(f);
|
2003-09-26 13:49:28 +00:00
|
|
|
glewDestroyContext();
|
2003-07-06 15:01:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-09-26 13:49:28 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
2003-09-26 14:45:00 +00:00
|
|
|
HWND wnd = NULL;
|
|
|
|
HDC dc = NULL;
|
|
|
|
HGLRC rc = NULL;
|
|
|
|
|
2003-09-26 13:49:28 +00:00
|
|
|
GLboolean glewCreateContext ()
|
|
|
|
{
|
|
|
|
WNDCLASS wc;
|
|
|
|
PIXELFORMATDESCRIPTOR pfd;
|
|
|
|
int pf;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* register window class */
|
2003-09-26 13:49:28 +00:00
|
|
|
ZeroMemory(&wc, sizeof(WNDCLASS));
|
|
|
|
wc.hInstance = GetModuleHandle(NULL);
|
|
|
|
wc.lpfnWndProc = DefWindowProc;
|
|
|
|
wc.lpszClassName = "GLEW";
|
|
|
|
if (0 == RegisterClass(&wc)) return GL_TRUE;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* create window */
|
2003-09-26 13:49:28 +00:00
|
|
|
wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
|
|
|
|
if (NULL == wnd) return GL_TRUE;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* get the device context */
|
2003-09-26 13:49:28 +00:00
|
|
|
dc = GetDC(wnd);
|
|
|
|
if (NULL == dc) return GL_TRUE;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* find pixel format */
|
2003-09-26 13:49:28 +00:00
|
|
|
ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
|
|
|
|
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
|
|
|
pfd.nVersion = 1;
|
|
|
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
|
|
|
|
pf = ChoosePixelFormat(dc, &pfd);
|
|
|
|
if (pf == 0) return GL_TRUE;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* set the pixel format for the dc */
|
2003-09-26 13:49:28 +00:00
|
|
|
if (FALSE == SetPixelFormat(dc, pf, &pfd)) return GL_TRUE;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* create rendering context */
|
2003-09-26 13:49:28 +00:00
|
|
|
rc = wglCreateContext(dc);
|
|
|
|
if (NULL == rc) return GL_TRUE;
|
|
|
|
if (FALSE == wglMakeCurrent(dc, rc)) return GL_TRUE;
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void glewDestroyContext ()
|
|
|
|
{
|
|
|
|
if (NULL != rc) wglMakeCurrent(NULL, NULL);
|
|
|
|
if (NULL != rc) wglDeleteContext(wglGetCurrentContext());
|
|
|
|
if (NULL != wnd && NULL != dc) ReleaseDC(wnd, dc);
|
|
|
|
if (NULL != wnd) DestroyWindow(wnd);
|
|
|
|
UnregisterClass("GLEW", GetModuleHandle(NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
# ifdef __APPLE__
|
|
|
|
|
2003-09-27 06:56:18 +00:00
|
|
|
Display* dpy = NULL;
|
|
|
|
XVisualInfo* vi = NULL;
|
|
|
|
GLXContext ctx = NULL;
|
|
|
|
Window wnd;
|
|
|
|
Colormap cmap;
|
|
|
|
|
2003-09-26 13:49:28 +00:00
|
|
|
GLboolean glewCreateContext ()
|
|
|
|
{
|
2003-09-27 06:56:18 +00:00
|
|
|
int attrib[] = { GLX_RGBA, None };
|
|
|
|
int erb, evb;
|
|
|
|
XSetWindowAttributes swa;
|
|
|
|
/* open display */
|
|
|
|
dpy = XOpenDisplay(NULL);
|
|
|
|
if (NULL == dpy) return GL_TRUE;
|
|
|
|
/* query for glx */
|
|
|
|
if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE;
|
|
|
|
/* choose visual */
|
|
|
|
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib);
|
|
|
|
if (NULL == vi) return GL_TRUE;
|
|
|
|
/* create context */
|
|
|
|
ctx = glXCreateContext(dpy, vi, None, True);
|
|
|
|
if (NULL == ctx) return GL_TRUE;
|
|
|
|
/* create window */
|
|
|
|
/*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/
|
|
|
|
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
|
|
|
|
swa.border_pixel = 0;
|
|
|
|
swa.colormap = cmap;
|
|
|
|
wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 256, 256, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap, &swa);
|
|
|
|
/* make context current */
|
|
|
|
if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE;
|
|
|
|
return GL_FALSE;
|
2003-09-26 13:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void glewDestroyContext ()
|
|
|
|
{
|
2003-09-27 06:56:18 +00:00
|
|
|
if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx);
|
|
|
|
if (NULL != dpy) XDestroyWindow(dpy, wnd);
|
|
|
|
if (NULL != dpy) XFreeColormap(dpy, cmap);
|
|
|
|
if (NULL != vi) XFree(vi);
|
|
|
|
if (NULL != dpy) XCloseDisplay(dpy);
|
2003-09-26 13:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# else /* __linux || __sgi */
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2003-09-26 14:45:00 +00:00
|
|
|
Display* dpy = NULL;
|
|
|
|
XVisualInfo* vi = NULL;
|
|
|
|
GLXContext ctx = NULL;
|
|
|
|
Window wnd;
|
2003-09-26 16:07:24 +00:00
|
|
|
Colormap cmap;
|
2003-09-26 14:17:28 +00:00
|
|
|
|
2003-09-26 13:49:28 +00:00
|
|
|
GLboolean glewCreateContext ()
|
|
|
|
{
|
2003-09-26 14:45:00 +00:00
|
|
|
int attrib[] = { GLX_RGBA, None };
|
2003-09-26 14:17:28 +00:00
|
|
|
int erb, evb;
|
2003-09-26 16:07:24 +00:00
|
|
|
XSetWindowAttributes swa;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* open display */
|
|
|
|
dpy = XOpenDisplay(NULL);
|
|
|
|
if (NULL == dpy) return GL_TRUE;
|
|
|
|
/* query for glx */
|
2003-09-26 14:45:00 +00:00
|
|
|
if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE;
|
2003-09-26 14:17:28 +00:00
|
|
|
/* choose visual */
|
|
|
|
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib);
|
|
|
|
if (NULL == vi) return GL_TRUE;
|
|
|
|
/* create context */
|
|
|
|
ctx = glXCreateContext(dpy, vi, None, True);
|
|
|
|
if (NULL == ctx) return GL_TRUE;
|
|
|
|
/* create window */
|
2003-09-26 16:33:19 +00:00
|
|
|
/*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/
|
2003-09-26 16:07:24 +00:00
|
|
|
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
|
|
|
|
swa.border_pixel = 0;
|
|
|
|
swa.colormap = cmap;
|
2003-09-26 16:34:47 +00:00
|
|
|
wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 256, 256, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap, &swa);
|
2003-09-26 16:33:19 +00:00
|
|
|
/* make context current */
|
2003-09-26 14:17:28 +00:00
|
|
|
if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE;
|
|
|
|
return GL_FALSE;
|
2003-09-26 13:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void glewDestroyContext ()
|
|
|
|
{
|
2003-09-26 14:45:00 +00:00
|
|
|
if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx);
|
|
|
|
if (NULL != dpy) XDestroyWindow(dpy, wnd);
|
2003-09-26 16:12:10 +00:00
|
|
|
if (NULL != dpy) XFreeColormap(dpy, cmap);
|
2003-09-26 14:45:00 +00:00
|
|
|
if (NULL != vi) XFree(vi);
|
|
|
|
if (NULL != dpy) XCloseDisplay(dpy);
|
2003-09-26 13:49:28 +00:00
|
|
|
}
|
|
|
|
|
2003-09-26 14:17:28 +00:00
|
|
|
# endif /* __linux || __sgi */
|
2003-09-26 13:49:28 +00:00
|
|
|
|
|
|
|
#endif
|