From 92a958306757bafde390801f056c196d08b7a603 Mon Sep 17 00:00:00 2001 From: ikits Date: Fri, 26 Sep 2003 14:45:00 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@138 783a27ee-832a-0410-bc00-9f386506c6dd --- Makefile | 6 +++--- auto/src/glewinfo_post.c | 43 +++++++++++++++------------------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index c85b1ec..d27bd26 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ LD = ld CFLAGS.EXTRA = LDFLAGS.SO = -shared -soname $(LIB.SONAME) LDFLAGS.EXTRA = -L/usr/X11R6/lib -LDFLAGS.GL = -lXmu -Xi -lGLU -lGL -lXext -lX11 +LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11 NAME = GLEW WARN = -Wall -W BIN.SUFFIX = @@ -109,7 +109,7 @@ LD = cc CFLAGS.EXTRA = -dynamic -I/usr/X11R6/include LDFLAGS.SO = -dynamiclib LDFLAGS.EXTRA = -L/usr/X11R6/lib -LDFLAGS.GL = -lXmu -Xi -lGLU -lGL -lXext -lX11 +LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11 NAME = GLEW BIN.SUFFIX = WARN = -Wall -W @@ -150,7 +150,7 @@ BIN.SRCS = src/glewinfo.c BIN.OBJS = $(BIN.SRCS:.c=.o) BIN.LIBS = -Llib -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL) -all: lib/$(LIB.SHARED) lib/$(LIB.STATIC) bin/$(BIN) +all debug: lib/$(LIB.SHARED) lib/$(LIB.STATIC) bin/$(BIN) lib: mkdir lib diff --git a/auto/src/glewinfo_post.c b/auto/src/glewinfo_post.c index ef904e4..a1e839f 100644 --- a/auto/src/glewinfo_post.c +++ b/auto/src/glewinfo_post.c @@ -49,14 +49,15 @@ int main () #ifdef _WIN32 +HWND wnd = NULL; +HDC dc = NULL; +HGLRC rc = NULL; + GLboolean glewCreateContext () { WNDCLASS wc; - HWND wnd; - HDC dc; PIXELFORMATDESCRIPTOR pfd; int pf; - HGLRC rc; /* register window class */ ZeroMemory(&wc, sizeof(WNDCLASS)); wc.hInstance = GetModuleHandle(NULL); @@ -87,9 +88,6 @@ GLboolean glewCreateContext () void glewDestroyContext () { - HWND wnd = FindWindow("GLEW", "GLEW"); - HGLRC rc = wglGetCurrentContext(); - HDC dc = wglGetCurrentDC(); if (NULL != rc) wglMakeCurrent(NULL, NULL); if (NULL != rc) wglDeleteContext(wglGetCurrentContext()); if (NULL != wnd && NULL != dc) ReleaseDC(wnd, dc); @@ -115,50 +113,41 @@ void glewDestroyContext () /* ------------------------------------------------------------------------ */ -Display* dpy; -XVisualInfo* vi; -GLXContext context; -Window window; +Display* dpy = NULL; +XVisualInfo* vi = NULL; +GLXContext ctx = NULL; +Window wnd; GLboolean glewCreateContext () { - Colormap cmap; - XSetWindowAttributes swa; + int attrib[] = { GLX_RGBA, None }; int erb, evb; - int attrib[] = { None }; /* open display */ dpy = XOpenDisplay(NULL); if (NULL == dpy) return GL_TRUE; /* query for glx */ - if (!glXQueryExtension(display, &erb, &evb)) return GL_TRUE; + 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 colormap */ - //cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); /* create window */ - //swa.colormap = cmap; - wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 0, vi->depth, - InputOutput, vi->visual, 0, &swa); - //XMapWindow(dpy, wnd); + wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 0, 0, 0); + /* make context current */ if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE; return GL_FALSE; } void glewDestroyContext () { - XUnmapWindow(dpy, wnd); - XDestroyWindow(dpy, wnd); - //XFreeColormap(dpy, cmap); - glXDestroyContext(dpy, ctx); - XFree(vi); - XCloseDisplay(dpy); + if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx); + if (NULL != dpy) XDestroyWindow(dpy, wnd); + if (NULL != vi) XFree(vi); + if (NULL != dpy) XCloseDisplay(dpy); } # endif /* __linux || __sgi */ #endif -