mirror of
https://github.com/reactos/reactos.git
synced 2025-06-15 09:58:29 +00:00
[D3DRM] Sync with Wine Staging 1.9.23. CORE-12409
svn path=/trunk/; revision=73250
This commit is contained in:
parent
e5a3cf92da
commit
b4b72c9302
9 changed files with 145 additions and 58 deletions
|
@ -29,6 +29,7 @@
|
|||
#define NONAMELESSUNION
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
|
@ -156,4 +157,19 @@ struct d3drm_file_header
|
|||
|
||||
extern char templates[] DECLSPEC_HIDDEN;
|
||||
|
||||
static inline BYTE d3drm_color_component(float c)
|
||||
{
|
||||
if (c <= 0.0f)
|
||||
return 0u;
|
||||
if (c >= 1.0f)
|
||||
return 0xffu;
|
||||
return floor(c * 255.0f);
|
||||
}
|
||||
|
||||
static inline void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a)
|
||||
{
|
||||
*color = RGBA_MAKE(d3drm_color_component(r), d3drm_color_component(g),
|
||||
d3drm_color_component(b), d3drm_color_component(a));
|
||||
}
|
||||
|
||||
#endif /* __D3DRM_PRIVATE_INCLUDED__ */
|
||||
|
|
|
@ -202,7 +202,7 @@ static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, ID
|
|||
{
|
||||
IDirectDraw *ddraw;
|
||||
IDirectDrawSurface *surface;
|
||||
IDirect3DDevice2 *d3d_device2;
|
||||
IDirect3DDevice2 *d3d_device2 = NULL;
|
||||
DDSURFACEDESC desc;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -212,9 +212,6 @@ static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, ID
|
|||
IDirect3DRM_AddRef(device->d3drm);
|
||||
IDirect3DDevice_AddRef(d3d_device);
|
||||
|
||||
if (device->ddraw)
|
||||
return D3DRMERR_BADOBJECT;
|
||||
|
||||
/* Fetch render target and get width/height from there */
|
||||
if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
|
||||
{
|
||||
|
@ -226,16 +223,26 @@ static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, ID
|
|||
return hr;
|
||||
}
|
||||
|
||||
if (device->ddraw)
|
||||
{
|
||||
if (d3d_device2)
|
||||
IDirectDrawSurface_Release(surface);
|
||||
return D3DRMERR_BADOBJECT;
|
||||
}
|
||||
|
||||
desc.dwSize = sizeof(desc);
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
IDirectDrawSurface_Release(surface);
|
||||
return hr;
|
||||
}
|
||||
|
||||
device->ddraw = ddraw;
|
||||
device->width = desc.dwWidth;
|
||||
device->height = desc.dwHeight;
|
||||
device->device = d3d_device;
|
||||
device->render_target = surface;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -1128,7 +1135,7 @@ static D3DCOLORMODEL WINAPI d3drm_device1_GetColorModel(IDirect3DRMDevice *iface
|
|||
{
|
||||
struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
|
||||
|
||||
TRACE("iface %p stub!\n", iface);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
|
||||
}
|
||||
|
@ -1562,7 +1569,7 @@ static HRESULT WINAPI d3drm_device_win_GetName(IDirect3DRMWinDevice *iface, DWOR
|
|||
{
|
||||
struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
|
||||
|
||||
TRACE("iface %p, size %p, name %p stub!\n", iface, size, name);
|
||||
TRACE("iface %p, size %p, name %p.\n", iface, size, name);
|
||||
|
||||
return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
|
||||
}
|
||||
|
|
|
@ -1329,23 +1329,53 @@ static HRESULT WINAPI d3drm_frame1_GetRotation(IDirect3DRMFrame *iface,
|
|||
|
||||
static HRESULT WINAPI d3drm_frame3_GetScene(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 **scene)
|
||||
{
|
||||
FIXME("iface %p, scene %p stub!\n", iface, scene);
|
||||
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, scene %p.\n", iface, scene);
|
||||
|
||||
if (!scene)
|
||||
return D3DRMERR_BADVALUE;
|
||||
|
||||
while (frame->parent)
|
||||
frame = frame->parent;
|
||||
|
||||
*scene = &frame->IDirect3DRMFrame3_iface;
|
||||
IDirect3DRMFrame3_AddRef(*scene);
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3drm_frame2_GetScene(IDirect3DRMFrame2 *iface, IDirect3DRMFrame **scene)
|
||||
{
|
||||
FIXME("iface %p, scene %p stub!\n", iface, scene);
|
||||
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
|
||||
IDirect3DRMFrame3 *frame3;
|
||||
HRESULT hr;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, scene %p.\n", iface, scene);
|
||||
|
||||
if (!scene)
|
||||
return D3DRMERR_BADVALUE;
|
||||
|
||||
hr = IDirect3DRMFrame3_GetScene(&frame->IDirect3DRMFrame3_iface, &frame3);
|
||||
if (FAILED(hr) || !frame3)
|
||||
{
|
||||
*scene = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = IDirect3DRMFrame3_QueryInterface(frame3, &IID_IDirect3DRMFrame, (void **)scene);
|
||||
IDirect3DRMFrame3_Release(frame3);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3drm_frame1_GetScene(IDirect3DRMFrame *iface, IDirect3DRMFrame **scene)
|
||||
{
|
||||
FIXME("iface %p, scene %p stub!\n", iface, scene);
|
||||
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, scene %p.\n", iface, scene);
|
||||
|
||||
return d3drm_frame2_GetScene(&frame->IDirect3DRMFrame2_iface, scene);
|
||||
}
|
||||
|
||||
static D3DRMSORTMODE WINAPI d3drm_frame3_GetSortMode(IDirect3DRMFrame3 *iface)
|
||||
|
@ -1962,10 +1992,9 @@ static HRESULT WINAPI d3drm_frame3_SetSceneBackgroundRGB(IDirect3DRMFrame3 *ifac
|
|||
{
|
||||
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
|
||||
|
||||
TRACE("iface %p, red %.8e, green %.8e, blue %.8e stub!\n", iface, red, green, blue);
|
||||
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
|
||||
|
||||
frame->scenebackground = RGBA_MAKE((BYTE)(red * 255.0f),
|
||||
(BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
|
||||
d3drm_set_color(&frame->scenebackground, red, green, blue, 1.0f);
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
@ -2909,7 +2938,7 @@ HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, I
|
|||
object->IDirect3DRMFrame3_iface.lpVtbl = &d3drm_frame3_vtbl;
|
||||
object->d3drm = d3drm;
|
||||
object->ref = 1;
|
||||
object->scenebackground = RGBA_MAKE(0, 0, 0, 0xff);
|
||||
d3drm_set_color(&object->scenebackground, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
memcpy(object->transform, identity, sizeof(D3DRMMATRIX4D));
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
|
|||
|
||||
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
|
||||
|
||||
light->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
|
||||
d3drm_set_color(&light->color, red, green, blue, 1.0f);
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
|
|
@ -24,25 +24,16 @@
|
|||
/* Create a RGB color from its components */
|
||||
D3DCOLOR WINAPI D3DRMCreateColorRGB(D3DVALUE red, D3DVALUE green, D3DVALUE blue)
|
||||
{
|
||||
return (D3DRMCreateColorRGBA(red, green, blue, 255.0));
|
||||
return D3DRMCreateColorRGBA(red, green, blue, 1.0f);
|
||||
}
|
||||
/* Create a RGBA color from its components */
|
||||
D3DCOLOR WINAPI D3DRMCreateColorRGBA(D3DVALUE red, D3DVALUE green, D3DVALUE blue, D3DVALUE alpha)
|
||||
{
|
||||
int Red, Green, Blue, Alpha;
|
||||
Red=floor(red*255);
|
||||
Green=floor(green*255);
|
||||
Blue=floor(blue*255);
|
||||
Alpha=floor(alpha*255);
|
||||
if (red < 0) Red=0;
|
||||
if (red > 1) Red=255;
|
||||
if (green < 0) Green=0;
|
||||
if (green > 1) Green=255;
|
||||
if (blue < 0) Blue=0;
|
||||
if (blue > 1) Blue=255;
|
||||
if (alpha < 0) Alpha=0;
|
||||
if (alpha > 1) Alpha=255;
|
||||
return (RGBA_MAKE(Red, Green, Blue, Alpha));
|
||||
D3DCOLOR color;
|
||||
|
||||
d3drm_set_color(&color, red, green, blue, alpha);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/* Determine the alpha part of a color */
|
||||
|
|
|
@ -1222,8 +1222,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData,
|
|||
|
||||
values = (float*)ptr;
|
||||
|
||||
This->materials[i].color = RGBA_MAKE((BYTE)(values[0] * 255.0f), (BYTE)(values[1] * 255.0f),
|
||||
(BYTE)(values[2] * 255.0f), (BYTE)(values[3] * 255.0f));
|
||||
d3drm_set_color(&This->materials[i].color, values[0], values[1], values[2], values[3]);
|
||||
|
||||
IDirect3DRMMaterial2_SetAmbient(This->materials[i].material, values[0], values [1], values[2]); /* Alpha ignored */
|
||||
IDirect3DRMMaterial2_SetPower(This->materials[i].material, values[4]);
|
||||
|
@ -1681,7 +1680,7 @@ static HRESULT WINAPI d3drm_mesh_builder3_SetColorRGB(IDirect3DRMMeshBuilder3 *i
|
|||
|
||||
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
|
||||
|
||||
mesh_builder->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
|
||||
d3drm_set_color(&mesh_builder->color, red, green, blue, 1.0f);
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
@ -2198,7 +2197,7 @@ static HRESULT WINAPI d3drm_mesh_builder3_GetNormals(IDirect3DRMMeshBuilder3 *if
|
|||
struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
|
||||
DWORD count = mesh_builder->nb_normals - start_idx;
|
||||
|
||||
TRACE("iface %p, start_idx %u, normal_count %p, normals %p stub!\n",
|
||||
TRACE("iface %p, start_idx %u, normal_count %p, normals %p.\n",
|
||||
iface, start_idx, normal_count, normals);
|
||||
|
||||
if (normal_count)
|
||||
|
@ -2582,7 +2581,7 @@ static HRESULT WINAPI d3drm_mesh_SetGroupColorRGB(IDirect3DRMMesh *iface,
|
|||
if (id >= mesh->nb_groups)
|
||||
return D3DRMERR_BADVALUE;
|
||||
|
||||
mesh->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
|
||||
d3drm_set_color(&mesh->groups[id].color, red, green, blue, 1.0f);
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ static HRESULT WINAPI d3drm_texture1_SetDecalSize(IDirect3DRMTexture *iface, D3D
|
|||
{
|
||||
struct d3drm_texture *texture = impl_from_IDirect3DRMTexture(iface);
|
||||
|
||||
TRACE("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
|
||||
TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
|
||||
|
||||
return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ static HRESULT WINAPI d3drm_texture2_SetDecalSize(IDirect3DRMTexture2 *iface, D3
|
|||
{
|
||||
struct d3drm_texture *texture = impl_from_IDirect3DRMTexture2(iface);
|
||||
|
||||
TRACE("iface %p, width %.8e, height %.8e stub!\n", iface, width, height);
|
||||
TRACE("iface %p, width %.8e, height %.8e.\n", iface, width, height);
|
||||
|
||||
return IDirect3DRMTexture3_SetDecalSize(&texture->IDirect3DRMTexture3_iface, width, height);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,32 @@ static inline struct d3drm_viewport *impl_from_IDirect3DRMViewport2(IDirect3DRMV
|
|||
return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport2_iface);
|
||||
}
|
||||
|
||||
static inline void d3drm_normalize_d3d_color(D3DCOLORVALUE *color_value, D3DCOLOR color)
|
||||
{
|
||||
color_value->u1.r = RGBA_GETRED(color) / 255.0f;
|
||||
color_value->u2.g = RGBA_GETGREEN(color) / 255.0f;
|
||||
color_value->u3.b = RGBA_GETBLUE(color) / 255.0f;
|
||||
color_value->u4.a = RGBA_GETALPHA(color) / 255.0f;
|
||||
}
|
||||
|
||||
static HRESULT d3drm_update_background_material(struct d3drm_viewport *viewport)
|
||||
{
|
||||
IDirect3DRMFrame *root_frame;
|
||||
D3DCOLOR color;
|
||||
D3DMATERIAL mat;
|
||||
HRESULT hr;
|
||||
|
||||
if (FAILED(hr = IDirect3DRMFrame_GetScene(viewport->camera, &root_frame)))
|
||||
return hr;
|
||||
color = IDirect3DRMFrame_GetSceneBackground(root_frame);
|
||||
|
||||
memset(&mat, 0, sizeof(mat));
|
||||
mat.dwSize = sizeof(mat);
|
||||
d3drm_normalize_d3d_color(&mat.u.diffuse, color);
|
||||
|
||||
return IDirect3DMaterial_SetMaterial(viewport->material, &mat);
|
||||
}
|
||||
|
||||
static void d3drm_viewport_destroy(struct d3drm_viewport *viewport)
|
||||
{
|
||||
TRACE("viewport %p releasing attached interfaces.\n", viewport);
|
||||
|
@ -275,10 +301,8 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
|
|||
D3DVIEWPORT vp;
|
||||
D3DVALUE scale;
|
||||
IDirect3D *d3d1 = NULL;
|
||||
D3DCOLOR color;
|
||||
IDirect3DDevice *d3d_device = NULL;
|
||||
IDirect3DMaterial *material = NULL;
|
||||
D3DMATERIAL mat;
|
||||
D3DMATERIALHANDLE hmat;
|
||||
HRESULT hr = D3DRM_OK;
|
||||
|
||||
|
@ -328,21 +352,9 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
|
|||
if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(camera, &IID_IDirect3DRMFrame, (void **)&viewport->camera)))
|
||||
goto cleanup;
|
||||
|
||||
color = IDirect3DRMFrame3_GetSceneBackground(camera);
|
||||
/* Create material (ambient/diffuse/emissive?), set material */
|
||||
if (FAILED(hr = IDirect3D_CreateMaterial(d3d1, &material, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
memset(&mat, 0, sizeof(mat));
|
||||
mat.dwSize = sizeof(mat);
|
||||
mat.u.diffuse.u1.r = RGBA_GETRED(color) / 255.0f;
|
||||
mat.u.diffuse.u2.g = RGBA_GETGREEN(color) / 255.0f;
|
||||
mat.u.diffuse.u3.b = RGBA_GETBLUE(color) / 255.0f;
|
||||
mat.u.diffuse.u4.a = RGBA_GETALPHA(color) / 255.0f;
|
||||
|
||||
if (FAILED(hr = IDirect3DMaterial_SetMaterial(material, &mat)))
|
||||
goto cleanup;
|
||||
|
||||
if (FAILED(hr = IDirect3DMaterial_GetHandle(material, d3d_device, &hmat)))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -399,16 +411,49 @@ static HRESULT WINAPI d3drm_viewport1_Init(IDirect3DRMViewport *iface, IDirect3D
|
|||
|
||||
static HRESULT WINAPI d3drm_viewport2_Clear(IDirect3DRMViewport2 *iface, DWORD flags)
|
||||
{
|
||||
FIXME("iface %p, flags %#x.\n", iface, flags);
|
||||
struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
|
||||
DDSCAPS caps = { DDSCAPS_ZBUFFER };
|
||||
HRESULT hr;
|
||||
D3DRECT clear_rect;
|
||||
IDirectDrawSurface *ds;
|
||||
DWORD clear_flags = 0;
|
||||
|
||||
TRACE("iface %p, flags %#x.\n", iface, flags);
|
||||
|
||||
clear_rect.u1.x1 = clear_rect.u2.y1 = 0;
|
||||
clear_rect.u3.x2 = viewport->device->width;
|
||||
clear_rect.u4.y2 = viewport->device->height;
|
||||
|
||||
if (flags & D3DRMCLEAR_TARGET)
|
||||
{
|
||||
clear_flags |= D3DCLEAR_TARGET;
|
||||
d3drm_update_background_material(viewport);
|
||||
}
|
||||
if (flags & D3DRMCLEAR_ZBUFFER)
|
||||
{
|
||||
hr = IDirectDrawSurface_GetAttachedSurface(viewport->device->render_target, &caps, &ds);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
clear_flags |= D3DCLEAR_ZBUFFER;
|
||||
IDirectDrawSurface_Release(ds);
|
||||
}
|
||||
}
|
||||
if (flags & D3DRMCLEAR_DIRTYRECTS)
|
||||
FIXME("Flag D3DRMCLEAR_DIRTYRECT not implemented yet.\n");
|
||||
|
||||
if (FAILED(hr = IDirect3DViewport_Clear(viewport->d3d_viewport, 1, &clear_rect, clear_flags)))
|
||||
return hr;
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3drm_viewport1_Clear(IDirect3DRMViewport *iface)
|
||||
{
|
||||
FIXME("iface %p.\n", iface);
|
||||
struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
|
||||
|
||||
return D3DRM_OK;
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return d3drm_viewport2_Clear(&viewport->IDirect3DRMViewport2_iface, D3DRMCLEAR_ALL);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3drm_viewport2_Render(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *frame)
|
||||
|
|
|
@ -25,7 +25,7 @@ reactos/dll/directx/wine/amstream # Synced to WineStaging-1.9.23
|
|||
reactos/dll/directx/wine/d3d8 # Synced to WineStaging-1.9.4
|
||||
reactos/dll/directx/wine/d3d9 # Synced to WineStaging-1.9.4
|
||||
reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-1.9.4
|
||||
reactos/dll/directx/wine/d3drm # Synced to WineStaging-1.9.16
|
||||
reactos/dll/directx/wine/d3drm # Synced to WineStaging-1.9.23
|
||||
reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-1.9.4
|
||||
reactos/dll/directx/wine/d3dxof # Synced to WineStaging-1.9.16
|
||||
reactos/dll/directx/wine/ddraw # Synced to WineStaging-1.9.4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue