Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: third_party/glew/src/glew.c

Issue 2856022: Added support to GLEW for dynamically looking up the core WGL entry... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/glew/include/GL/wglew.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** The OpenGL Extension Wrangler Library 2 ** The OpenGL Extension Wrangler Library
3 ** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org> 3 ** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
4 ** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org> 4 ** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
5 ** Copyright (C) 2002, Lev Povalahev 5 ** Copyright (C) 2002, Lev Povalahev
6 ** All rights reserved. 6 ** All rights reserved.
7 ** 7 **
8 ** Redistribution and use in source and binary forms, with or without 8 ** Redistribution and use in source and binary forms, with or without
9 ** modification, are permitted provided that the following conditions are met: 9 ** modification, are permitted provided that the following conditions are met:
10 ** 10 **
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 # define GLEW_CONTEXT_ARG_DEF_LIST void 65 # define GLEW_CONTEXT_ARG_DEF_LIST void
66 # define WGLEW_CONTEXT_ARG_DEF_INIT void 66 # define WGLEW_CONTEXT_ARG_DEF_INIT void
67 # define WGLEW_CONTEXT_ARG_DEF_LIST void 67 # define WGLEW_CONTEXT_ARG_DEF_LIST void
68 # define GLXEW_CONTEXT_ARG_DEF_INIT void 68 # define GLXEW_CONTEXT_ARG_DEF_INIT void
69 # define GLXEW_CONTEXT_ARG_DEF_LIST void 69 # define GLXEW_CONTEXT_ARG_DEF_LIST void
70 # define GLXEW_CONTEXT_ARG_DEF_DPY_LIST Display* dpy 70 # define GLXEW_CONTEXT_ARG_DEF_DPY_LIST Display* dpy
71 # define GLXEW_CONTEXT_ARG_DEF_DPY_INIT 71 # define GLXEW_CONTEXT_ARG_DEF_DPY_INIT
72 #endif /* GLEW_MX */ 72 #endif /* GLEW_MX */
73 73
74 #ifdef _WIN32 74 #ifdef _WIN32
75
76 #ifndef GLEW_MX
77 void* WinGetProcAddress(const GLubyte* name);
78
79 GLboolean wglewInit()
80 {
81 GLboolean r = GL_FALSE;
82
83 r = ((wglewCopyContext = (PFNWGLCOPYCONTEXTPROC)WinGetProcAddress((const GLuby te*)"wglCopyContext")) == NULL) || r;
84 r = ((wglewCreateContext = (PFNWGLCREATECONTEXTPROC)WinGetProcAddress((const G Lubyte*)"wglCreateContext")) == NULL) || r;
85 r = ((wglewCreateLayerContext = (PFNWGLCREATELAYERCONTEXTPROC)WinGetProcAddres s((const GLubyte*)"wglCreateLayerContext")) == NULL) || r;
86 r = ((wglewDeleteContext = (PFNWGLDELETECONTEXTPROC)WinGetProcAddress((const G Lubyte*)"wglDeleteContext")) == NULL) || r;
87 r = ((wglewGetCurrentContext = (PFNWGLGETCURRENTCONTEXTPROC)WinGetProcAddress( (const GLubyte*)"wglGetCurrentContext")) == NULL) || r;
88 r = ((wglewGetCurrentDC = (PFNWGLGETCURRENTDCPROC)WinGetProcAddress((const GLu byte*)"wglGetCurrentDC")) == NULL) || r;
89 r = ((wglewGetProcAddress = (PFNWGLGETPROCADDRESSPROC)WinGetProcAddress((const GLubyte*)"wglGetProcAddress")) == NULL) || r;
90 r = ((wglewMakeCurrent = (PFNWGLMAKECURRENTPROC)WinGetProcAddress((const GLuby te*)"wglMakeCurrent")) == NULL) || r;
91 r = ((wglewShareLists = (PFNWGLSHARELISTSPROC)WinGetProcAddress((const GLubyte *)"wglShareLists")) == NULL) || r;
92 r = ((wglewSwapBuffers = (PFNSWAPBUFFERSPROC)WinGetProcAddress((const GLubyte* )"SwapBuffers")) == NULL) || r;
93
94 return !r;
95 }
96 #endif /* !GLEW_MX */
97
75 void* WinGetProcAddress(const GLubyte* name) 98 void* WinGetProcAddress(const GLubyte* name)
76 { 99 {
77 /* Need to use GetProcAddress to bootstrap things now that we are 100 /* Need to use GetProcAddress to bootstrap things now that we are
78 dynamically looking up OpenGL 1.1 entry points as well. */ 101 dynamically looking up OpenGL 1.1 entry points as well. */
79 static HMODULE oglImage = NULL; 102 static HMODULE oglImage = NULL;
103 static HMODULE gdi32Image = NULL; // For SwapBuffers.
80 static PFNOSMESAGETPROCADDRESSPROC osmesaGetProcAddress = NULL; 104 static PFNOSMESAGETPROCADDRESSPROC osmesaGetProcAddress = NULL;
81 void* proc = NULL; 105 void* proc = NULL;
82 106
83 if (NULL == oglImage) { 107 if (NULL == oglImage) {
84 oglImage = LoadLibraryA("osmesa.dll"); 108 oglImage = LoadLibraryA("osmesa.dll");
85 if (NULL == oglImage) { 109 if (NULL == oglImage) {
86 oglImage = LoadLibraryA("opengl32.dll"); 110 oglImage = LoadLibraryA("opengl32.dll");
111 #ifndef GLEW_MX
112 if (NULL != oglImage) {
113 gdi32Image = LoadLibraryA("gdi32.dll");
114 wglewInit();
115 }
116 #endif /* !GLEW_MX */
87 } 117 }
88 else { 118 else {
89 osmesaGetProcAddress = (PFNOSMESAGETPROCADDRESSPROC) GetProcAddress(oglIma ge, "OSMesaGetProcAddress"); 119 osmesaGetProcAddress = (PFNOSMESAGETPROCADDRESSPROC) GetProcAddress(oglIma ge, "OSMesaGetProcAddress");
90 } 120 }
91 } 121 }
92 if (NULL != oglImage) { 122 if (NULL != oglImage) {
93 proc = (void*) GetProcAddress(oglImage, (LPCSTR) name); 123 proc = (void*) GetProcAddress(oglImage, (LPCSTR) name);
124 #ifndef GLEW_MX
125 if (NULL == proc) {
126 proc = (void*) GetProcAddress(gdi32Image, (LPCSTR) name);
127 }
128 #endif
94 } 129 }
95 if (NULL == proc) { 130 if (NULL == proc) {
96 if (osmesaGetProcAddress) { 131 if (osmesaGetProcAddress) {
97 proc = osmesaGetProcAddress(name); 132 proc = osmesaGetProcAddress(name);
98 } 133 }
134 #ifdef GLEW_MX
99 else { 135 else {
100 proc = wglGetProcAddress((LPCSTR) name); 136 proc = wglGetProcAddress((LPCSTR) name);
101 } 137 }
138 #else
139 else if (wglewGetProcAddress) {
140 proc = wglewGetProcAddress((LPCSTR) name);
141 }
142 #endif
102 } 143 }
103 return proc; 144 return proc;
104 } 145 }
105 146
106 #endif /* _WIN32 */ 147 #endif /* _WIN32 */
107 148
108 #if defined(__APPLE__) 149 #if defined(__APPLE__)
109 #include <dlfcn.h> 150 #include <dlfcn.h>
110 #include <stdlib.h> 151 #include <stdlib.h>
111 #include <string.h> 152 #include <string.h>
(...skipping 7958 matching lines...) Expand 10 before | Expand all | Expand 10 after
8070 #endif /* GL_WIN_swap_hint */ 8111 #endif /* GL_WIN_swap_hint */
8071 8112
8072 return GLEW_OK; 8113 return GLEW_OK;
8073 } 8114 }
8074 8115
8075 8116
8076 #if defined(_WIN32) 8117 #if defined(_WIN32)
8077 8118
8078 #if !defined(GLEW_MX) 8119 #if !defined(GLEW_MX)
8079 8120
8121 PFNWGLCOPYCONTEXTPROC __wglewCopyContext = NULL;
8122 PFNWGLCREATECONTEXTPROC __wglewCreateContext = NULL;
8123 PFNWGLCREATELAYERCONTEXTPROC __wglewCreateLayerContext = NULL;
8124 PFNWGLDELETECONTEXTPROC __wglewDeleteContext = NULL;
8125 PFNWGLGETCURRENTCONTEXTPROC __wglewGetCurrentContext = NULL;
8126 PFNWGLGETCURRENTDCPROC __wglewGetCurrentDC = NULL;
8127 PFNWGLGETPROCADDRESSPROC __wglewGetProcAddress = NULL;
8128 PFNWGLMAKECURRENTPROC __wglewMakeCurrent = NULL;
8129 PFNWGLSHARELISTSPROC __wglewShareLists = NULL;
8130 PFNSWAPBUFFERSPROC __wglewSwapBuffers = NULL;
8131
8080 PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL; 8132 PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL;
8081 8133
8082 PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL; 8134 PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL;
8083 PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL; 8135 PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL;
8084 PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL; 8136 PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL;
8085 PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB = NULL; 8137 PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB = NULL;
8086 8138
8087 PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB = NULL; 8139 PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB = NULL;
8088 8140
8089 PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB = NULL; 8141 PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB = NULL;
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
8707 { 8759 {
8708 GLubyte* p; 8760 GLubyte* p;
8709 GLubyte* end; 8761 GLubyte* end;
8710 GLuint len = _glewStrLen((const GLubyte*)name); 8762 GLuint len = _glewStrLen((const GLubyte*)name);
8711 if (_wglewGetExtensionsStringARB == NULL) 8763 if (_wglewGetExtensionsStringARB == NULL)
8712 if (_wglewGetExtensionsStringEXT == NULL) 8764 if (_wglewGetExtensionsStringEXT == NULL)
8713 return GL_FALSE; 8765 return GL_FALSE;
8714 else 8766 else
8715 p = (GLubyte*)_wglewGetExtensionsStringEXT(); 8767 p = (GLubyte*)_wglewGetExtensionsStringEXT();
8716 else 8768 else
8717 p = (GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC()); 8769 p = (GLubyte*)_wglewGetExtensionsStringARB(wglewGetCurrentDC());
8718 if (0 == p) return GL_FALSE; 8770 if (0 == p) return GL_FALSE;
8719 end = p + _glewStrLen(p); 8771 end = p + _glewStrLen(p);
8720 while (p < end) 8772 while (p < end)
8721 { 8773 {
8722 GLuint n = _glewStrCLen(p, ' '); 8774 GLuint n = _glewStrCLen(p, ' ');
8723 if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; 8775 if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
8724 p += n+1; 8776 p += n+1;
8725 } 8777 }
8726 return GL_FALSE; 8778 return GL_FALSE;
8727 } 8779 }
(...skipping 4278 matching lines...) Expand 10 before | Expand all | Expand 10 after
13006 } 13058 }
13007 #endif 13059 #endif
13008 } 13060 }
13009 } 13061 }
13010 ret = (len == 0); 13062 ret = (len == 0);
13011 } 13063 }
13012 return ret; 13064 return ret;
13013 } 13065 }
13014 13066
13015 #endif /* _WIN32 */ 13067 #endif /* _WIN32 */
OLDNEW
« no previous file with comments | « third_party/glew/include/GL/wglew.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698