Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9ca3a224
Commit
9ca3a224
authored
Aug 16, 2007
by
Roderick Colenbrander
Committed by
Alexandre Julliard
Aug 17, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Dynamically load WGL functions.
parent
06cc0fa9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
38 deletions
+55
-38
context.c
dlls/wined3d/context.c
+11
-11
directx.c
dlls/wined3d/directx.c
+26
-27
wined3d_gl.h
include/wine/wined3d_gl.h
+18
-0
No files found.
dlls/wined3d/context.c
View file @
9ca3a224
...
...
@@ -266,8 +266,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
}
}
ctx
=
wglCreateContext
(
hdc
);
if
(
This
->
numContexts
)
wglShareLists
(
This
->
contexts
[
0
]
->
glCtx
,
ctx
);
ctx
=
p
wglCreateContext
(
hdc
);
if
(
This
->
numContexts
)
p
wglShareLists
(
This
->
contexts
[
0
]
->
glCtx
,
ctx
);
if
(
!
ctx
)
{
ERR
(
"Failed to create a WGL context
\n
"
);
...
...
@@ -280,7 +280,7 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
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
);
p
wglDeleteContext
(
ctx
);
if
(
create_pbuffer
)
{
GL_EXTCALL
(
wglReleasePbufferDCARB
(
pbuffer
,
hdc
));
GL_EXTCALL
(
wglDestroyPbufferARB
(
pbuffer
));
...
...
@@ -294,9 +294,9 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
TRACE
(
"Successfully created new context %p
\n
"
,
ret
);
/* Set up the context defaults */
oldCtx
=
wglGetCurrentContext
();
oldDrawable
=
wglGetCurrentDC
();
if
(
wglMakeCurrent
(
hdc
,
ctx
)
==
FALSE
)
{
oldCtx
=
p
wglGetCurrentContext
();
oldDrawable
=
p
wglGetCurrentDC
();
if
(
p
wglMakeCurrent
(
hdc
,
ctx
)
==
FALSE
)
{
ERR
(
"Cannot activate context to set up defaults
\n
"
);
goto
out
;
}
...
...
@@ -368,7 +368,7 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
}
if
(
oldDrawable
&&
oldCtx
)
{
wglMakeCurrent
(
oldDrawable
,
oldCtx
);
p
wglMakeCurrent
(
oldDrawable
,
oldCtx
);
}
out:
...
...
@@ -430,15 +430,15 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) {
/* check that we are the current context first */
TRACE
(
"Destroying ctx %p
\n
"
,
context
);
if
(
wglGetCurrentContext
()
==
context
->
glCtx
){
wglMakeCurrent
(
NULL
,
NULL
);
if
(
p
wglGetCurrentContext
()
==
context
->
glCtx
){
p
wglMakeCurrent
(
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
);
p
wglDeleteContext
(
context
->
glCtx
);
RemoveContextFromArray
(
This
,
context
);
}
...
...
@@ -831,7 +831,7 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
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
=
p
wglMakeCurrent
(
context
->
hdc
,
context
->
glCtx
);
ENTER_GL
();
if
(
ret
==
FALSE
)
{
ERR
(
"Failed to activate the new context
\n
"
);
...
...
dlls/wined3d/directx.c
View file @
9ca3a224
...
...
@@ -168,14 +168,14 @@ static void WineD3D_ReleaseFakeGLContext(void) {
return
;
}
glCtx
=
wglGetCurrentContext
();
glCtx
=
p
wglGetCurrentContext
();
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
);
p
wglMakeCurrent
(
NULL
,
NULL
);
p
wglDeleteContext
(
glCtx
);
}
if
(
wined3d_fake_gl_context_hdc
)
ReleaseDC
(
wined3d_fake_gl_context_hwnd
,
wined3d_fake_gl_context_hdc
);
...
...
@@ -203,7 +203,7 @@ static BOOL WineD3D_CreateFakeGLContext(void) {
wined3d_fake_gl_context_foreign
=
TRUE
;
glCtx
=
wglGetCurrentContext
();
glCtx
=
p
wglGetCurrentContext
();
if
(
!
glCtx
)
{
PIXELFORMATDESCRIPTOR
pfd
;
int
iPixelFormat
;
...
...
@@ -241,14 +241,14 @@ static BOOL WineD3D_CreateFakeGLContext(void) {
SetPixelFormat
(
wined3d_fake_gl_context_hdc
,
iPixelFormat
,
&
pfd
);
/* Create a GL context */
glCtx
=
wglCreateContext
(
wined3d_fake_gl_context_hdc
);
glCtx
=
p
wglCreateContext
(
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
(
!
p
wglMakeCurrent
(
wined3d_fake_gl_context_hdc
,
glCtx
))
{
WARN_
(
d3d_caps
)(
"Error setting default context as current for capabilities initialization
\n
"
);
goto
fail
;
}
...
...
@@ -267,7 +267,7 @@ static BOOL WineD3D_CreateFakeGLContext(void) {
if
(
wined3d_fake_gl_context_hwnd
)
DestroyWindow
(
wined3d_fake_gl_context_hwnd
);
wined3d_fake_gl_context_hwnd
=
NULL
;
if
(
glCtx
)
wglDeleteContext
(
glCtx
);
if
(
glCtx
)
p
wglDeleteContext
(
glCtx
);
LeaveCriticalSection
(
&
wined3d_fake_gl_context_cs
);
LEAVE_GL
();
return
FALSE
;
...
...
@@ -404,35 +404,26 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
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*)p
wglGetProcAddress(
#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
;
}
...
...
@@ -441,6 +432,14 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
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"
;
...
...
@@ -607,7 +606,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
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) p
wglGetProcAddress(
#pfn);
GL_EXT_FUNCS_GEN
;
WGL_EXT_FUNCS_GEN
;
#undef USE_GL_FUNC
...
...
@@ -1009,7 +1008,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
/* TODO: config lookups */
/* Make sure there's an active HDC else the WGL extensions will fail */
hdc
=
wglGetCurrentDC
();
hdc
=
p
wglGetCurrentDC
();
if
(
hdc
)
{
WGL_Extensions
=
GL_EXTCALL
(
wglGetExtensionsStringARB
(
hdc
));
TRACE_
(
d3d_caps
)(
"WGL_Extensions reported:
\n
"
);
...
...
include/wine/wined3d_gl.h
View file @
9ca3a224
...
...
@@ -1138,6 +1138,15 @@ void (WINE_GLAPI *glVertex4sv) (const GLshort* v);
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) \
...
...
@@ -1476,6 +1485,15 @@ void (WINE_GLAPI *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment