*** empty log message ***

git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@219 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
ikits 2004-02-02 02:25:18 +00:00
parent 2b006727bd
commit af4e79fedb
2 changed files with 58 additions and 42 deletions

View File

@ -12,14 +12,22 @@ int main (int argc, char** argv)
if (glewParseArgs(argc-1, argv+1, &display, &visual)) if (glewParseArgs(argc-1, argv+1, &display, &visual))
{ {
#ifdef _WIN32 #if defined(_WIN32)
fprintf(stderr, "Usage: glewinfo [-pf <id>]\n"); fprintf(stderr, "Usage: glewinfo [-pf <id>]\n");
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
fprintf(stderr, "Usage: glewinfo\n");
#else #else
fprintf(stderr, "Usage: glewinfo [-display <display>] [-visual <id>]\n"); fprintf(stderr, "Usage: glewinfo [-display <display>] [-visual <id>]\n");
#endif #endif
return 1; return 1;
} }
#if defined(_WIN32)
if (GL_TRUE == glewCreateContext(&visual))
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
if (GL_TRUE == glewCreateContext())
#else
if (GL_TRUE == glewCreateContext(display, &visual)) if (GL_TRUE == glewCreateContext(display, &visual))
#endif
{ {
fprintf(stderr, "Error: glewCreateContext failed\n"); fprintf(stderr, "Error: glewCreateContext failed\n");
glewDestroyContext(); glewDestroyContext();
@ -33,7 +41,7 @@ int main (int argc, char** argv)
glewDestroyContext(); glewDestroyContext();
return 1; return 1;
} }
#ifdef _WIN32 #if defined(_WIN32)
f = fopen("glewinfo.txt", "w"); f = fopen("glewinfo.txt", "w");
if (f == NULL) f = stdout; if (f == NULL) f = stdout;
#else #else
@ -43,9 +51,9 @@ int main (int argc, char** argv)
fprintf(f, " GLEW Extension Info\n"); fprintf(f, " GLEW Extension Info\n");
fprintf(f, "---------------------------\n\n"); fprintf(f, "---------------------------\n\n");
fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION)); fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
#ifdef _WIN32 #if defined(_WIN32)
fprintf(f, "Reporting capabilities of pixelformat %d\n", visual); fprintf(f, "Reporting capabilities of pixelformat %d\n", visual);
#else #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n", fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n",
display == NULL ? getenv("DISPLAY") : display, visual); display == NULL ? getenv("DISPLAY") : display, visual);
#endif #endif
@ -53,9 +61,9 @@ int main (int argc, char** argv)
glGetString(GL_RENDERER), glGetString(GL_VENDOR)); glGetString(GL_RENDERER), glGetString(GL_VENDOR));
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION)); fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
glewInfo(); glewInfo();
#ifdef _WIN32 #if defined(_WIN32)
wglewInfo(); wglewInfo();
#else #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
glxewInfo(); glxewInfo();
#endif #endif
if (f != stdout) fclose(f); if (f != stdout) fclose(f);
@ -70,27 +78,29 @@ GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual)
int p = 0; int p = 0;
while (p < argc) while (p < argc)
{ {
#ifdef _WIN32 #if defined(_WIN32)
if (!strcmp(argv[p], "-pf")) if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat"))
{
if (++p >= argc) return GL_TRUE;
*visual = atoi(argv[p++]);
}
else
return GL_TRUE;
#else
if (!strcmp(argv[p], "-display"))
{
if (++p >= argc) return GL_TRUE;
*display = argv[p++];
}
else if (!strcmp(argv[p], "-visual") || !strcmp(argv[p], "-pf"))
{ {
if (++p >= argc) return GL_TRUE; if (++p >= argc) return GL_TRUE;
*visual = strtol(argv[p++], NULL, 0); *visual = strtol(argv[p++], NULL, 0);
} }
else else
return GL_TRUE; return GL_TRUE;
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
if (!strcmp(argv[p], "-display"))
{
if (++p >= argc) return GL_TRUE;
*display = argv[p++];
}
else if (!strcmp(argv[p], "-visual"))
{
if (++p >= argc) return GL_TRUE;
*visual = strtol(argv[p++], NULL, 0);
}
else
return GL_TRUE;
#else
return GL_TRUE;
#endif #endif
} }
return GL_FALSE; return GL_FALSE;
@ -98,13 +108,13 @@ GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
#ifdef _WIN32 #if defined(_WIN32)
HWND wnd = NULL; HWND wnd = NULL;
HDC dc = NULL; HDC dc = NULL;
HGLRC rc = NULL; HGLRC rc = NULL;
GLboolean glewCreateContext (int* visual) GLboolean glewCreateContext (int* pixelformat)
{ {
WNDCLASS wc; WNDCLASS wc;
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
@ -115,23 +125,24 @@ GLboolean glewCreateContext (int* visual)
wc.lpszClassName = "GLEW"; wc.lpszClassName = "GLEW";
if (0 == RegisterClass(&wc)) return GL_TRUE; if (0 == RegisterClass(&wc)) return GL_TRUE;
/* create window */ /* create window */
wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL); wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
if (NULL == wnd) return GL_TRUE; if (NULL == wnd) return GL_TRUE;
/* get the device context */ /* get the device context */
dc = GetDC(wnd); dc = GetDC(wnd);
if (NULL == dc) return GL_TRUE; if (NULL == dc) return GL_TRUE;
/* find pixel format */ /* find pixel format */
ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
if (*visual == -1) /* find default */ if (*pixelformat == -1) /* find default */
{ {
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1; pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
*visual = ChoosePixelFormat(dc, &pfd); *pixelformat = ChoosePixelFormat(dc, &pfd);
if (*visual == 0) return GL_TRUE; if (*pixelformat == 0) return GL_TRUE;
} }
/* set the pixel format for the dc */ /* set the pixel format for the dc */
if (FALSE == SetPixelFormat(dc, *visual, &pfd)) return GL_TRUE; if (FALSE == SetPixelFormat(dc, *pixelformat, &pfd)) return GL_TRUE;
/* create rendering context */ /* create rendering context */
rc = wglCreateContext(dc); rc = wglCreateContext(dc);
if (NULL == rc) return GL_TRUE; if (NULL == rc) return GL_TRUE;
@ -148,11 +159,9 @@ void glewDestroyContext ()
UnregisterClass("GLEW", GetModuleHandle(NULL)); UnregisterClass("GLEW", GetModuleHandle(NULL));
} }
#else
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
# if defined(__APPLE__) && !defined(GLEW_APPLE_GLX) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
#include <AGL/agl.h> #include <AGL/agl.h>
@ -162,16 +171,16 @@ GLboolean glewCreateContext ()
{ {
int attrib[] = { AGL_RGBA, AGL_NONE }; int attrib[] = { AGL_RGBA, AGL_NONE };
AGLPixelFormat pf; AGLPixelFormat pf;
//int major, minor; /*int major, minor;
//SetPortWindowPort(wnd); SetPortWindowPort(wnd);
//aglGetVersion(&major, &minor); aglGetVersion(&major, &minor);
//fprintf(stderr, "GL %d.%d\n", major, minor); fprintf(stderr, "GL %d.%d\n", major, minor);*/
pf = aglChoosePixelFormat(NULL, 0, attrib); pf = aglChoosePixelFormat(NULL, 0, attrib);
if (NULL == pf) return GL_TRUE; if (NULL == pf) return GL_TRUE;
ctx = aglCreateContext(pf, NULL); ctx = aglCreateContext(pf, NULL);
if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE; if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE;
aglDestroyPixelFormat(pf); aglDestroyPixelFormat(pf);
//aglSetDrawable(ctx, GetWindowPort(wnd)); /*aglSetDrawable(ctx, GetWindowPort(wnd));*/
octx = aglGetCurrentContext(); octx = aglGetCurrentContext();
if (NULL == aglSetCurrentContext(ctx)) return GL_TRUE; if (NULL == aglSetCurrentContext(ctx)) return GL_TRUE;
return GL_FALSE; return GL_FALSE;
@ -183,10 +192,10 @@ void glewDestroyContext ()
if (NULL != ctx) aglDestroyContext(ctx); if (NULL != ctx) aglDestroyContext(ctx);
} }
# else /* __linux || __sgi || (__APPLE__ && GLEW_APPLE_GLX) */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
#else /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */
Display* dpy = NULL; Display* dpy = NULL;
XVisualInfo* vi = NULL; XVisualInfo* vi = NULL;
XVisualInfo* vis = NULL; XVisualInfo* vis = NULL;
@ -230,7 +239,9 @@ GLboolean glewCreateContext (const char* display, int* visual)
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
swa.border_pixel = 0; swa.border_pixel = 0;
swa.colormap = cmap; swa.colormap = cmap;
wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 256, 256, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap, &swa); wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen),
0, 0, 1, 1, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap, &swa);
/* make context current */ /* make context current */
if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE; if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE;
return GL_FALSE; return GL_FALSE;
@ -248,6 +259,4 @@ void glewDestroyContext ()
if (NULL != dpy) XCloseDisplay(dpy); if (NULL != dpy) XCloseDisplay(dpy);
} }
# endif /* __linux || __sgi */ #endif /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */
#endif

View File

@ -41,7 +41,14 @@
static FILE* f; static FILE* f;
#if defined(_WIN32)
GLboolean glewCreateContext (int* pixelformat);
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
GLboolean glewCreateContext (const char* display, int* visual); GLboolean glewCreateContext (const char* display, int* visual);
#else
GLboolean glewCreateContext ();
#endif
GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual); GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual);
void glewDestroyContext (); void glewDestroyContext ();