From 031afdf03be1d123b7a442f64cfa28c6066c1490 Mon Sep 17 00:00:00 2001 From: ikits Date: Fri, 26 Sep 2003 13:49:28 +0000 Subject: [PATCH] removed GLUT dependency git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@135 783a27ee-832a-0410-bc00-9f386506c6dd --- auto/src/glew_pre.c | 2 +- auto/src/glewinfo_post.c | 95 ++++++++++++++++++++++++++++++++++++++-- auto/src/glewinfo_pre.c | 10 ++++- build/vc6/glewinfo.dsp | 4 +- 4 files changed, 104 insertions(+), 7 deletions(-) diff --git a/auto/src/glew_pre.c b/auto/src/glew_pre.c index 5279c13..a32d93d 100644 --- a/auto/src/glew_pre.c +++ b/auto/src/glew_pre.c @@ -59,7 +59,7 @@ static void* NSGLGetProcAddress (const char* name) { NSSymbol symbol; char* symbolName; - // Prepend a '_' for the Unix C symbol mangling convention + /* prepend a '_' for the Unix C symbol mangling convention */ symbolName = malloc(strlen(name) + 2); strcpy(symbolName+1, name); symbolName[0] = '_'; diff --git a/auto/src/glewinfo_post.c b/auto/src/glewinfo_post.c index 07e8e6a..bcfb9a7 100644 --- a/auto/src/glewinfo_post.c +++ b/auto/src/glewinfo_post.c @@ -4,16 +4,21 @@ /* ------------------------------------------------------------------------ */ -int main (int argc, char** argv) +int main () { GLuint err; - glutInit(&argc, argv); - glutCreateWindow("GLEW Extension Info"); + if (GL_TRUE == glewCreateContext()) + { + fprintf(stderr, "Error: glewCreateContext failed\n"); + glewDestroyContext(); + return 1; + } glewExperimental = GL_TRUE; err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); + glewDestroyContext(); return 1; } #ifdef _WIN32 @@ -36,5 +41,89 @@ int main (int argc, char** argv) glxewInfo(); #endif if (f != stdout) fclose(f); + glewDestroyContext(); return 0; } + +/* ------------------------------------------------------------------------ */ + +#ifdef _WIN32 + +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); + wc.lpfnWndProc = DefWindowProc; + wc.lpszClassName = "GLEW"; + if (0 == RegisterClass(&wc)) return GL_TRUE; + // create window + wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL); + if (NULL == wnd) return GL_TRUE; + // get the device context + dc = GetDC(wnd); + if (NULL == dc) return GL_TRUE; + // find pixel format + 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; + // set the pixel format for the dc + if (FALSE == SetPixelFormat(dc, pf, &pfd)) return GL_TRUE; + // create rendering context + rc = wglCreateContext(dc); + if (NULL == rc) return GL_TRUE; + if (FALSE == wglMakeCurrent(dc, rc)) return GL_TRUE; + return GL_FALSE; +} + +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); + if (NULL != wnd) DestroyWindow(wnd); + UnregisterClass("GLEW", GetModuleHandle(NULL)); +} + +#else + +/* ------------------------------------------------------------------------ */ + +# ifdef __APPLE__ + +GLboolean glewCreateContext () +{ +} + +void glewDestroyContext () +{ +} + +# else /* __linux || __sgi */ + +/* ------------------------------------------------------------------------ */ + +GLboolean glewCreateContext () +{ +} + +void glewDestroyContext () +{ +} + +# endif + +#endif + diff --git a/auto/src/glewinfo_pre.c b/auto/src/glewinfo_pre.c index f1285d0..fc7126b 100644 --- a/auto/src/glewinfo_pre.c +++ b/auto/src/glewinfo_pre.c @@ -32,12 +32,20 @@ #include #include #include -#include #include #include +#ifdef _WIN32 +#include +#endif + static FILE* f; +GLboolean glewCreateContext (); +void glewDestroyContext (); + +/* ------------------------------------------------------------------------- */ + static void glewPrintExt (const GLubyte* name, GLint defined) { unsigned int i; diff --git a/build/vc6/glewinfo.dsp b/build/vc6/glewinfo.dsp index 9c5133d..93bca7d 100644 --- a/build/vc6/glewinfo.dsp +++ b/build/vc6/glewinfo.dsp @@ -50,7 +50,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 ../../lib/glew32s.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ../../lib/glew32s.lib opengl32.lib gdi32.lib user32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "glewinfo - Win32 Debug" @@ -74,7 +74,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ../../lib/glew32sd.lib /nologo /subsystem:console /incremental:no /pdb:"static/debug/glewinfod.pdb" /debug /machine:I386 /out:"../../bin/glewinfod.exe" /pdbtype:sept +# ADD LINK32 ../../lib/glew32sd.lib opengl32.lib gdi32.lib user32.lib /nologo /subsystem:console /incremental:no /pdb:"static/debug/glewinfod.pdb" /debug /machine:I386 /out:"../../bin/glewinfod.exe" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ENDIF