}
}
- ctx = wglCreateContext(hdc);
- if(This->numContexts) wglShareLists(This->contexts[0]->glCtx, ctx);
+ ctx = pwglCreateContext(hdc);
+ if(This->numContexts) pwglShareLists(This->contexts[0]->glCtx, ctx);
if(!ctx) {
ERR("Failed to create a WGL context\n");
ret = AddContextToArray(This, win_handle, hdc, ctx, pbuffer);
if(!ret) {
ERR("Failed to add the newly created context to the context list\n");
- wglDeleteContext(ctx);
+ pwglDeleteContext(ctx);
if(create_pbuffer) {
GL_EXTCALL(wglReleasePbufferDCARB(pbuffer, hdc));
GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
TRACE("Successfully created new context %p\n", ret);
/* Set up the context defaults */
- oldCtx = wglGetCurrentContext();
- oldDrawable = wglGetCurrentDC();
- if(wglMakeCurrent(hdc, ctx) == FALSE) {
+ oldCtx = pwglGetCurrentContext();
+ oldDrawable = pwglGetCurrentDC();
+ if(pwglMakeCurrent(hdc, ctx) == FALSE) {
ERR("Cannot activate context to set up defaults\n");
goto out;
}
}
if(oldDrawable && oldCtx) {
- wglMakeCurrent(oldDrawable, oldCtx);
+ pwglMakeCurrent(oldDrawable, oldCtx);
}
out:
/* check that we are the current context first */
TRACE("Destroying ctx %p\n", context);
- if(wglGetCurrentContext() == context->glCtx){
- wglMakeCurrent(NULL, NULL);
+ if(pwglGetCurrentContext() == context->glCtx){
+ pwglMakeCurrent(NULL, NULL);
}
if(context->isPBuffer) {
GL_EXTCALL(wglReleasePbufferDCARB(context->pbuffer, context->hdc));
GL_EXTCALL(wglDestroyPbufferARB(context->pbuffer));
} else ReleaseDC(context->win_handle, context->hdc);
- wglDeleteContext(context->glCtx);
+ pwglDeleteContext(context->glCtx);
RemoveContextFromArray(This, context);
}
BOOL ret;
TRACE("Switching gl ctx to %p, hdc=%p ctx=%p\n", context, context->hdc, context->glCtx);
LEAVE_GL();
- ret = wglMakeCurrent(context->hdc, context->glCtx);
+ ret = pwglMakeCurrent(context->hdc, context->glCtx);
ENTER_GL();
if(ret == FALSE) {
ERR("Failed to activate the new context\n");
return;
}
- glCtx = wglGetCurrentContext();
+ glCtx = pwglGetCurrentContext();
TRACE_(d3d_caps)("decrementing ref from %i\n", wined3d_fake_gl_context_ref);
if (0 == (--wined3d_fake_gl_context_ref) ) {
if(!wined3d_fake_gl_context_foreign && glCtx) {
TRACE_(d3d_caps)("destroying fake GL context\n");
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(glCtx);
+ pwglMakeCurrent(NULL, NULL);
+ pwglDeleteContext(glCtx);
}
if(wined3d_fake_gl_context_hdc)
ReleaseDC(wined3d_fake_gl_context_hwnd, wined3d_fake_gl_context_hdc);
wined3d_fake_gl_context_foreign = TRUE;
- glCtx = wglGetCurrentContext();
+ glCtx = pwglGetCurrentContext();
if (!glCtx) {
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat;
SetPixelFormat(wined3d_fake_gl_context_hdc, iPixelFormat, &pfd);
/* Create a GL context */
- glCtx = wglCreateContext(wined3d_fake_gl_context_hdc);
+ glCtx = pwglCreateContext(wined3d_fake_gl_context_hdc);
if (!glCtx) {
WARN_(d3d_caps)("Error creating default context for capabilities initialization\n");
goto fail;
}
/* Make it the current GL context */
- if (!wglMakeCurrent(wined3d_fake_gl_context_hdc, glCtx)) {
+ if (!pwglMakeCurrent(wined3d_fake_gl_context_hdc, glCtx)) {
WARN_(d3d_caps)("Error setting default context as current for capabilities initialization\n");
goto fail;
}
if(wined3d_fake_gl_context_hwnd)
DestroyWindow(wined3d_fake_gl_context_hwnd);
wined3d_fake_gl_context_hwnd = NULL;
- if(glCtx) wglDeleteContext(glCtx);
+ if(glCtx) pwglDeleteContext(glCtx);
LeaveCriticalSection(&wined3d_fake_gl_context_cs);
LEAVE_GL();
return FALSE;
int i;
HDC hdc;
HMODULE mod_gl;
- PROC (WINAPI *p_wglGetProcAddress)(LPCSTR lpszProc);
-
- /* Make sure that we've got a context */
- /* TODO: CreateFakeGLContext should really take a display as a parameter */
- /* Only save the values obtained when a display is provided */
- if (!WineD3D_CreateFakeGLContext() || wined3d_fake_gl_context_foreign)
- return_value = FALSE;
-
- TRACE_(d3d_caps)("(%p)\n", gl_info);
#ifdef USE_WIN32_OPENGL
-#define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, (const char *) #pfn);
+#define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
mod_gl = LoadLibraryA("opengl32.dll");
if(!mod_gl) {
ERR("Can't load opengl32.dll!\n");
return FALSE;
}
#else
-#define USE_GL_FUNC(pfn) pfn = (void*)p_wglGetProcAddress( (const char *) #pfn);
+#define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
/* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
- mod_gl = LoadLibraryA("gdi32.dll");
- if(!mod_gl) {
- ERR("Can't load gdi32.dll!\n");
- return FALSE;
- }
+ mod_gl = GetModuleHandleA("gdi32.dll");
#endif
- p_wglGetProcAddress = (void*)GetProcAddress(mod_gl, "wglGetProcAddress");
- if(!p_wglGetProcAddress) {
+/* Load WGL core functions from opengl32.dll */
+#define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
+ WGL_FUNCS_GEN;
+#undef USE_WGL_FUNC
+
+ if(!pwglGetProcAddress) {
ERR("Unable to load wglGetProcAddress!\n");
return FALSE;
}
GL_FUNCS_GEN;
#undef USE_GL_FUNC
+ /* Make sure that we've got a context */
+ /* TODO: CreateFakeGLContext should really take a display as a parameter */
+ /* Only save the values obtained when a display is provided */
+ if (!WineD3D_CreateFakeGLContext() || wined3d_fake_gl_context_foreign)
+ return_value = FALSE;
+
+ TRACE_(d3d_caps)("(%p)\n", gl_info);
+
gl_string = (const char *) glGetString(GL_RENDERER);
if (NULL == gl_string)
gl_string = "None";
gl_info->ps_arb_constantsF = 0;
/* Now work out what GL support this card really has */
-#define USE_GL_FUNC(type, pfn) gl_info->pfn = (type) p_wglGetProcAddress( (const char *) #pfn);
+#define USE_GL_FUNC(type, pfn) gl_info->pfn = (type) pwglGetProcAddress(#pfn);
GL_EXT_FUNCS_GEN;
WGL_EXT_FUNCS_GEN;
#undef USE_GL_FUNC
/* TODO: config lookups */
/* Make sure there's an active HDC else the WGL extensions will fail */
- hdc = wglGetCurrentDC();
+ hdc = pwglGetCurrentDC();
if (hdc) {
WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc));
TRACE_(d3d_caps)("WGL_Extensions reported:\n");
void (WINE_GLAPI *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
void (WINE_GLAPI *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
+/* WGL functions */
+HGLRC (WINAPI *pwglCreateContext)(HDC);
+BOOL (WINAPI *pwglDeleteContext)(HGLRC);
+HGLRC (WINAPI *pwglGetCurrentContext)(void);
+HDC (WINAPI *pwglGetCurrentDC)(void);
+PROC (WINAPI *pwglGetProcAddress)(LPCSTR);
+BOOL (WINAPI *pwglMakeCurrent)(HDC,HGLRC);
+BOOL (WINAPI *pwglShareLists)(HGLRC,HGLRC);
+
#define GL_FUNCS_GEN \
USE_GL_FUNC(glAccum) \
USE_GL_FUNC(glAlphaFunc) \
USE_GL_FUNC(glVertexPointer) \
USE_GL_FUNC(glViewport)
+#define WGL_FUNCS_GEN \
+ USE_WGL_FUNC(wglCreateContext) \
+ USE_WGL_FUNC(wglDeleteContext) \
+ USE_WGL_FUNC(wglGetCurrentContext) \
+ USE_WGL_FUNC(wglGetCurrentDC) \
+ USE_WGL_FUNC(wglGetProcAddress) \
+ USE_WGL_FUNC(wglMakeCurrent) \
+ USE_WGL_FUNC(wglShareLists)
+
/****************************************************
* OpenGL Extensions (EXT and ARB)