Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
ad725851
Commit
ad725851
authored
May 13, 1999
by
Lionel Ulmer
Committed by
Alexandre Julliard
May 13, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced all the Mesa specific code by GLX code. Should work now on
any OpenGL implementation.
parent
75793af6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
242 additions
and
31 deletions
+242
-31
direct3D
documentation/status/direct3D
+30
-24
d3d_private.h
graphics/d3d_private.h
+19
-0
d3dcommon.c
graphics/d3dcommon.c
+4
-0
d3ddevices.c
graphics/d3ddevices.c
+133
-2
d3dexecutebuffer.c
graphics/d3dexecutebuffer.c
+3
-0
d3dlight.c
graphics/d3dlight.c
+4
-0
d3dmaterial.c
graphics/d3dmaterial.c
+2
-0
d3dtexture.c
graphics/d3dtexture.c
+14
-0
d3dviewport.c
graphics/d3dviewport.c
+3
-1
ddraw.c
graphics/ddraw.c
+26
-4
ddraw_private.h
graphics/ddraw_private.h
+3
-0
wine_gl.h
include/wine_gl.h
+1
-0
No files found.
documentation/status/direct3D
View file @
ad725851
...
...
@@ -4,34 +4,36 @@ Introduction
This file contains information about Wine's implementation of
Direct3D.
The current version requires :
* Mesa (tested with version 3.1 beta)
* a display in 16bpp
To minimize the impact on DirectDraw (i.e. to reuse most of the code
already done for DirectDraw), I decided not to start with an
implementation based on GLX, but on OSMesa. This way, all the OpenGL
rendering are done in a 'private' memory buffer, buffer that will
copied back to the DirectDraw Surface each time a 3D scene
finishes. It is not optimal for execution speed (on each frame, the
OpenGL buffer is converted from 32 to 16 bpp and copied onto the
screen) but is for development (I had almost nothing to change in
DirectDraw). Moreover, 99 % of the code in the Direct3D implementation
is 'device independant' (i.e. GLX / OSMesa / whatever), so that
changing to GLX will have only a minor impact on Direct3D's code.
The current version has been tested using Mesa. For optimal
performances, you need at least Mesa 3.1 beta 2.
Where to find Mesa :
--------------------
The home of Mesa should soon be http://www.mesa3d.org/
But for now, check http://www.ssec.wisc.edu/~brianp/Mesa.html
For precompiled RPMs, use AltaVista or FTPSearch, but I prefer to 'Use
the Source' :-)
WARNING : if you experience crashes in D3DTexture2_Load, see file
d3dtexture.c for a 'cure'. You could also patch your version of Mesa
or wait for version 3.2b (that should have the bug corrected).
or get version 3.1 beta 2 or the latest CVS version.
How to configure Mesa :
-----------------------
For Mesa version > 3.1b2, you can configure the Voodoo driver to not
override the signal handlers (something that Wine does really not
like).
For that add the following lines to the /etc/mesa.conf file :
;; Profile for Wine
(config-mesa wine
((fx-catch-signals false)))
And do a 'export MESA_CONFIG=wine' before starting Wine.
Code structure
--------------
...
...
@@ -50,10 +52,15 @@ Some programs with which I tested the code :
* TWIST.EXE (DX3.0) : vertex transformation works as it
should. Texturing and lighting still off.
* Tomb Raider II (DX5.0) : works perfectly (but slowly). All the
calls needed to make TR2 work have been written.
* Tomb Raider II (DX5.0) : works perfectly (but slowly) in software
mode. All the calls needed to make TR2 work have been written. In
3D accelerated mode with a Voodoo board, it works fine except for
color keying (no transparent textures :/). This is being
investigated with the Mesa authors.
* Jedi Knight (DX3.0) : does not start
* Jedi Knight Demo (DX3.0) : works well with the old OSMesa
code. Works for the new GLX code but without the 'head-up' display
(because it is blitted directly on the frame-buffer :/)
* Shadow of the Empire demo (DX3.0) : displays a mangled intro screen
(only blue squares on the screen)
...
...
@@ -61,13 +68,12 @@ Some programs with which I tested the code :
* Forsaken Demo : starts to work. Texturing is missing and it is
really really slow.
* Grim Fandango (DX ?, seems to be 3.0 !!) : does not start.
* Grim Fandango (DX 3.0 !!) : works in DDraw mode. Some problems in
D3D mode as it does direct Z Buffer writing.
TODO
----
* work on optimizing Execute Buffers (i.e. Direct3D 3.0)
* real GLX implementation (will need a complete rewrite of DirectDraw
also) to have 3DFx support
* restructuration of all the DDRAW.DLL (put that in the dll
directory, better separation of 'drivers, ...)
* start looking into DirectX 6.0
...
...
@@ -78,4 +84,4 @@ TODO
--
Lionel Ulmer - ulmer@directprovider.net
Last updated :
Tue Jan 19
1999
Last updated :
Sat May 08
1999
graphics/d3d_private.h
View file @
ad725851
...
...
@@ -10,6 +10,10 @@
#include "wine_gl.h"
#include "d3d.h"
#include "x11drv.h"
#undef USE_OSMESA
/*****************************************************************************
* Predeclare the interface implementation structures
*/
...
...
@@ -228,6 +232,13 @@ struct IDirect3DDevice2Impl
#ifdef HAVE_MESAGL
#ifdef USE_OSMESA
#define LEAVE_GL() ;
#define ENTER_GL() ;
#else
#define LEAVE_GL() LeaveCriticalSection( &X11DRV_CritSection )
#define ENTER_GL() EnterCriticalSection( &X11DRV_CritSection )
#endif
/* Matrix copy WITH transposition */
#define conv_mat2(mat,gl_mat) \
...
...
@@ -281,8 +292,12 @@ typedef struct OpenGL_IDirect3DDevice2 {
IDirect3DDevice2Impl
common
;
/* These are the OpenGL-specific variables */
#ifdef USE_OSMESA
OSMesaContext
ctx
;
unsigned
char
*
buffer
;
#else
GLXContext
ctx
;
#endif
/* The current render state */
RenderState
rs
;
...
...
@@ -299,8 +314,12 @@ typedef struct OpenGL_IDirect3DDevice {
IDirect3DDeviceImpl
common
;
/* These are the OpenGL-specific variables */
#ifdef USE_OSMESA
OSMesaContext
ctx
;
unsigned
char
*
buffer
;
#else
GLXContext
ctx
;
#endif
/* The current render state */
RenderState
rs
;
...
...
graphics/d3dcommon.c
View file @
ad725851
...
...
@@ -122,6 +122,8 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
(
dwRenderStateType
<=
D3DRENDERSTATE_STIPPLEPATTERN31
))
{
ERR
(
ddraw
,
"Unhandled stipple !
\n
"
);
}
else
{
ENTER_GL
();
/* All others state variables */
switch
(
dwRenderStateType
)
{
...
...
@@ -338,6 +340,8 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
ERR
(
ddraw
,
"Unhandled Render State
\n
"
);
break
;
}
LEAVE_GL
();
}
}
...
...
graphics/d3ddevices.c
View file @
ad725851
This diff is collapsed.
Click to expand it.
graphics/d3dexecutebuffer.c
View file @
ad725851
...
...
@@ -186,6 +186,8 @@ static void execute(LPDIRECT3DEXECUTEBUFFER lpBuff,
if
(
TRACE_ON
(
ddraw
))
_dump_executedata
(
&
(
ilpBuff
->
data
));
ENTER_GL
();
while
(
1
)
{
LPD3DINSTRUCTION
current
=
(
LPD3DINSTRUCTION
)
instr
;
BYTE
size
;
...
...
@@ -657,6 +659,7 @@ static void execute(LPDIRECT3DEXECUTEBUFFER lpBuff,
}
end_of_buffer:
LEAVE_GL
();
}
/*******************************************************************************
...
...
graphics/d3dlight.c
View file @
ad725851
...
...
@@ -81,6 +81,7 @@ static void update(IDirect3DLightImpl* This) {
}
static
void
activate
(
IDirect3DLightImpl
*
This
)
{
ENTER_GL
();
update
(
This
);
/* If was not active, activate it */
...
...
@@ -89,6 +90,7 @@ static void activate(IDirect3DLightImpl* This) {
This
->
is_active
=
1
;
}
LEAVE_GL
();
return
;
}
...
...
@@ -220,8 +222,10 @@ static HRESULT WINAPI IDirect3DLightImpl_SetLight(LPDIRECT3DLIGHT iface,
break
;
}
ENTER_GL
();
if
(
This
->
is_active
)
update
(
This
);
LEAVE_GL
();
return
DD_OK
;
}
...
...
graphics/d3dmaterial.c
View file @
ad725851
...
...
@@ -27,6 +27,7 @@ static ICOM_VTABLE(IDirect3DMaterial) material_vtable;
static
void
activate
(
IDirect3DMaterial2Impl
*
This
)
{
TRACE
(
ddraw
,
"Activating material %p
\n
"
,
This
);
ENTER_GL
();
/* First, set the rendering context */
if
(
This
->
use_d3d2
)
This
->
device
.
active_device2
->
set_context
(
This
->
device
.
active_device2
);
...
...
@@ -55,6 +56,7 @@ static void activate(IDirect3DMaterial2Impl* This) {
TRACE
(
ddraw
,
"Power : %f
\n
"
,
This
->
mat
.
e
.
power
);
TRACE
(
ddraw
,
"Texture handle : %08lx
\n
"
,
(
DWORD
)
This
->
mat
.
hTexture
);
LEAVE_GL
();
return
;
}
...
...
graphics/d3dtexture.c
View file @
ad725851
...
...
@@ -142,11 +142,13 @@ HRESULT WINAPI SetColorKey_cb(IDirect3DTexture2Impl *texture, DWORD dwFlags, LP
tex_d
->
ddpfPixelFormat
.
x
.
dwRGBBitCount
/
8
/* RGB bits for each colors */
);
/* Now, save the current texture */
ENTER_GL
();
glGetIntegerv
(
GL_TEXTURE_BINDING_2D
,
&
current_texture
);
/* If the GetHandle was not done yet, it's an error */
if
(
texture
->
tex_name
==
0
)
{
ERR
(
ddraw
,
"Unloaded texture !
\n
"
);
LEAVE_GL
();
return
DD_OK
;
}
glBindTexture
(
GL_TEXTURE_2D
,
texture
->
tex_name
);
...
...
@@ -206,6 +208,7 @@ HRESULT WINAPI SetColorKey_cb(IDirect3DTexture2Impl *texture, DWORD dwFlags, LP
}
else
{
ERR
(
ddraw
,
"Unhandled texture format (neither RGB nor INDEX)
\n
"
);
}
LEAVE_GL
();
return
DD_OK
;
}
...
...
@@ -246,7 +249,9 @@ static ULONG WINAPI IDirect3DTexture2Impl_Release(LPDIRECT3DTEXTURE2 iface)
if
(
!--
(
This
->
ref
))
{
/* Delete texture from OpenGL */
ENTER_GL
();
glDeleteTextures
(
1
,
&
(
This
->
tex_name
));
LEAVE_GL
();
/* Release surface */
IDirectDrawSurface4_Release
((
IDirectDrawSurface4
*
)
This
->
surface
);
...
...
@@ -270,10 +275,12 @@ static HRESULT WINAPI IDirect3DTextureImpl_GetHandle(LPDIRECT3DTEXTURE iface,
*
lpHandle
=
(
D3DTEXTUREHANDLE
)
This
;
/* Now, bind a new texture */
ENTER_GL
();
ilpD3DDevice
->
set_context
(
ilpD3DDevice
);
This
->
D3Ddevice
=
(
void
*
)
ilpD3DDevice
;
if
(
This
->
tex_name
==
0
)
glGenTextures
(
1
,
&
(
This
->
tex_name
));
LEAVE_GL
();
TRACE
(
ddraw
,
"OpenGL texture handle is : %d
\n
"
,
This
->
tex_name
);
...
...
@@ -311,10 +318,12 @@ static HRESULT WINAPI IDirect3DTexture2Impl_GetHandle(LPDIRECT3DTEXTURE2 iface,
*
lpHandle
=
(
D3DTEXTUREHANDLE
)
This
;
/* Now, bind a new texture */
ENTER_GL
();
ilpD3DDevice2
->
set_context
(
ilpD3DDevice2
);
This
->
D3Ddevice
=
(
void
*
)
ilpD3DDevice2
;
if
(
This
->
tex_name
==
0
)
glGenTextures
(
1
,
&
(
This
->
tex_name
));
LEAVE_GL
();
TRACE
(
ddraw
,
"OpenGL texture handle is : %d
\n
"
,
This
->
tex_name
);
...
...
@@ -371,6 +380,8 @@ static HRESULT WINAPI IDirect3DTexture2Impl_Load(LPDIRECT3DTEXTURE2 iface,
texture object. */
memcpy
(
dst_d
->
y
.
lpSurface
,
src_d
->
y
.
lpSurface
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
bpp
);
ENTER_GL
();
/* Now, load the texture */
/* d3dd->set_context(d3dd); We need to set the context somehow.... */
glGetIntegerv
(
GL_TEXTURE_BINDING_2D
,
&
current_texture
);
...
...
@@ -390,6 +401,7 @@ static HRESULT WINAPI IDirect3DTexture2Impl_Load(LPDIRECT3DTEXTURE2 iface,
if
(
pal
==
NULL
)
{
ERR
(
ddraw
,
"Palettized texture Loading with a NULL palette !
\n
"
);
LEAVE_GL
();
return
D3DERR_TEXTURE_LOAD_FAILED
;
}
...
...
@@ -505,6 +517,8 @@ static HRESULT WINAPI IDirect3DTexture2Impl_Load(LPDIRECT3DTEXTURE2 iface,
}
glBindTexture
(
GL_TEXTURE_2D
,
current_texture
);
LEAVE_GL
();
}
return
D3D_OK
;
...
...
graphics/d3dviewport.c
View file @
ad725851
...
...
@@ -11,12 +11,12 @@
#include "ddraw.h"
#include "d3d.h"
#include "debug.h"
#include "x11drv.h"
#include "d3d_private.h"
DEFAULT_DEBUG_CHANNEL
(
ddraw
)
#ifdef HAVE_MESAGL
static
ICOM_VTABLE
(
IDirect3DViewport2
)
viewport2_vtable
;
...
...
@@ -249,10 +249,12 @@ static HRESULT WINAPI IDirect3DViewport2Impl_Clear(LPDIRECT3DVIEWPORT2 iface,
}
/* Clears the screen */
ENTER_GL
();
glGetBooleanv
(
GL_DEPTH_TEST
,
&
ztest
);
glDepthMask
(
GL_TRUE
);
/* Enables Z writing to be sure to delete also the Z buffer */
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDepthMask
(
ztest
);
LEAVE_GL
();
return
DD_OK
;
}
...
...
graphics/ddraw.c
View file @
ad725851
...
...
@@ -554,9 +554,9 @@ static HRESULT WINAPI IDirectDrawSurface4Impl_Lock(
FIXME
(
ddraw
,
" lprect: %dx%d-%dx%d
\n
"
,
lprect
->
top
,
lprect
->
left
,
lprect
->
bottom
,
lprect
->
right
);
lpddsd
->
y
.
lpSurface
=
(
char
*
)
This
->
s
.
surface_desc
.
y
.
lpSurface
+
lpddsd
->
y
.
lpSurface
=
(
LPVOID
)
((
char
*
)
This
->
s
.
surface_desc
.
y
.
lpSurface
+
(
lprect
->
top
*
This
->
s
.
surface_desc
.
lPitch
)
+
(
lprect
->
left
*
(
This
->
s
.
surface_desc
.
ddpfPixelFormat
.
x
.
dwRGBBitCount
/
8
));
(
lprect
->
left
*
(
This
->
s
.
surface_desc
.
ddpfPixelFormat
.
x
.
dwRGBBitCount
/
8
)
));
}
else
{
assert
(
This
->
s
.
surface_desc
.
y
.
lpSurface
);
}
...
...
@@ -666,6 +666,20 @@ static HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Flip(
ICOM_THIS
(
IDirectDrawSurface4Impl
,
iface
);
IDirectDrawSurface4Impl
*
iflipto
=
(
IDirectDrawSurface4Impl
*
)
flipto
;
TRACE
(
ddraw
,
"(%p)->Flip(%p,%08lx)
\n
"
,
This
,
iflipto
,
dwFlags
);
#ifdef HAVE_MESAGL
if
((
This
->
s
.
d3d_device
!=
NULL
)
||
((
This
->
s
.
backbuffer
!=
NULL
)
&&
(
This
->
s
.
backbuffer
->
s
.
d3d_device
!=
NULL
)))
{
TRACE
(
ddraw
,
" - OpenGL flip
\n
"
);
ENTER_GL
();
glXSwapBuffers
(
display
,
This
->
s
.
ddraw
->
d
.
drawable
);
LEAVE_GL
();
return
DD_OK
;
}
#endif
/* defined(HAVE_MESAGL) */
if
(
!
This
->
s
.
ddraw
->
d
.
paintable
)
return
DD_OK
;
...
...
@@ -2933,6 +2947,12 @@ static HRESULT WINAPI IDirectDraw2Impl_SetCooperativeLevel(
WND
*
tmpWnd
=
WIN_FindWndPtr
(
hwnd
);
This
->
d
.
drawable
=
X11DRV_WND_GetXWindow
(
tmpWnd
);
WIN_ReleaseWndPtr
(
tmpWnd
);
if
(
!
This
->
d
.
drawable
)
{
This
->
d
.
drawable
=
((
X11DRV_WND_DATA
*
)
WIN_GetDesktop
()
->
pDriverData
)
->
window
;
WIN_ReleaseDesktop
();
}
TRACE
(
ddraw
,
"Setting drawable to %ld
\n
"
,
This
->
d
.
drawable
);
}
return
DD_OK
;
...
...
@@ -3330,14 +3350,16 @@ static HRESULT WINAPI Xlib_IDirectDrawImpl_SetDisplayMode(
tmpWnd
=
WIN_FindWndPtr
(
This
->
d
.
window
);
This
->
d
.
paintable
=
1
;
This
->
d
.
drawable
=
((
X11DRV_WND_DATA
*
)
tmpWnd
->
pDriverData
)
->
window
;
/* We don't have a context for this window. Host off the desktop */
WIN_ReleaseWndPtr
(
tmpWnd
);
/* We don't have a context for this window. Host off the desktop */
if
(
!
This
->
d
.
drawable
)
{
This
->
d
.
drawable
=
((
X11DRV_WND_DATA
*
)
WIN_GetDesktop
()
->
pDriverData
)
->
window
;
WIN_ReleaseDesktop
();
}
WIN_ReleaseWndPtr
(
tmpWnd
);
TRACE
(
ddraw
,
"Setting drawable to %ld
\n
"
,
This
->
d
.
drawable
);
return
DD_OK
;
}
...
...
graphics/ddraw_private.h
View file @
ad725851
...
...
@@ -148,6 +148,9 @@ struct _common_directdrawsurface
/* Callback for loaded textures */
IDirect3DTexture2Impl
*
texture
;
HRESULT
WINAPI
(
*
SetColorKey_cb
)(
IDirect3DTexture2Impl
*
texture
,
DWORD
dwFlags
,
LPDDCOLORKEY
ckey
)
;
/* Storage for attached device (void * as it can be either a Device or a Device2) */
void
*
d3d_device
;
};
struct
_dga_directdrawsurface
...
...
include/wine_gl.h
View file @
ad725851
...
...
@@ -21,6 +21,7 @@
/* These will need to have some #ifdef / #endif added to support
more than the X11 using OSMesa target */
#include <GL/osmesa.h>
#include <GL/glx.h>
#undef APIENTRY
#undef CALLBACK
...
...
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