* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include "d3drm_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface,
DWORD width, DWORD height, IDirect3DRMDevice **device)
{
- struct d3drm_device *object;
- HRESULT hr;
-
- FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
-
- if (FAILED(hr = d3drm_device_create(&object, iface)))
- return hr;
+ TRACE("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
- *device = &object->IDirect3DRMDevice_iface;
+ if (!device)
+ return D3DRMERR_BADVALUE;
+ *device = NULL;
- return D3DRM_OK;
+ return D3DRMERR_BADDEVICE;
}
static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *guid,
TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
iface, device, camera, x, y, width, height, viewport);
- if (!device || !camera)
- return D3DRMERR_BADOBJECT;
if (!viewport)
return D3DRMERR_BADVALUE;
+ *viewport = NULL;
+
+ if (!device || !camera)
+ return D3DRMERR_BADOBJECT;
if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
return hr;
static HRESULT WINAPI d3drm2_CreateDevice(IDirect3DRM2 *iface,
DWORD width, DWORD height, IDirect3DRMDevice2 **device)
{
- struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
- struct d3drm_device *object;
- HRESULT hr;
-
- FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
-
- if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
- return hr;
+ TRACE("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
- *device = &object->IDirect3DRMDevice2_iface;
+ if (!device)
+ return D3DRMERR_BADVALUE;
+ *device = NULL;
- return D3DRM_OK;
+ return D3DRMERR_BADDEVICE;
}
static HRESULT WINAPI d3drm2_CreateDeviceFromSurface(IDirect3DRM2 *iface, GUID *guid,
TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
iface, device, camera, x, y, width, height, viewport);
- if (!device || !camera)
- return D3DRMERR_BADOBJECT;
if (!viewport)
return D3DRMERR_BADVALUE;
+ *viewport = NULL;
+
+ if (!device || !camera)
+ return D3DRMERR_BADOBJECT;
if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
return hr;
static HRESULT WINAPI d3drm3_CreateDevice(IDirect3DRM3 *iface,
DWORD width, DWORD height, IDirect3DRMDevice3 **device)
{
- struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
- struct d3drm_device *object;
- HRESULT hr;
-
- FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
+ TRACE("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
- if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
- return hr;
-
- *device = &object->IDirect3DRMDevice3_iface;
+ if (!device)
+ return D3DRMERR_BADVALUE;
+ *device = NULL;
- return D3DRM_OK;
+ return D3DRMERR_BADDEVICE;
}
static HRESULT WINAPI d3drm3_CreateDeviceFromSurface(IDirect3DRM3 *iface, GUID *guid,
TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
iface, device, camera, x, y, width, height, viewport);
- if (!device || !camera)
- return D3DRMERR_BADOBJECT;
if (!viewport)
return D3DRMERR_BADVALUE;
+ *viewport = NULL;
+
+ if (!device || !camera)
+ return D3DRMERR_BADOBJECT;
if (FAILED(hr = d3drm_viewport_create(&object, &d3drm->IDirect3DRM_iface)))
return hr;
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include "d3drm_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
-static D3DRMMATRIX4D identity = {
- { 1.0f, 0.0f, 0.0f, 0.0f },
- { 0.0f, 1.0f, 0.0f, 0.0f },
- { 0.0f, 0.0f, 1.0f, 0.0f },
- { 0.0f, 0.0f, 0.0f, 1.0f }
+static const struct d3drm_matrix identity =
+{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
};
struct d3drm_frame_array
return CONTAINING_RECORD(iface, struct d3drm_frame, IDirect3DRMFrame3_iface);
}
-static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface);
-
static inline struct d3drm_frame_array *impl_from_IDirect3DRMFrameArray(IDirect3DRMFrameArray *iface)
{
return CONTAINING_RECORD(iface, struct d3drm_frame_array, IDirect3DRMFrameArray_iface);
return CONTAINING_RECORD(iface, struct d3drm_animation, IDirect3DRMAnimation2_iface);
}
+static void d3drm_matrix_multiply_affine(struct d3drm_matrix *dst,
+ const struct d3drm_matrix *src1, const struct d3drm_matrix *src2)
+{
+ struct d3drm_matrix tmp;
+
+ tmp._11 = src1->_11 * src2->_11 + src1->_12 * src2->_21 + src1->_13 * src2->_31;
+ tmp._12 = src1->_11 * src2->_12 + src1->_12 * src2->_22 + src1->_13 * src2->_32;
+ tmp._13 = src1->_11 * src2->_13 + src1->_12 * src2->_23 + src1->_13 * src2->_33;
+ tmp._14 = 0.0f;
+
+ tmp._21 = src1->_21 * src2->_11 + src1->_22 * src2->_21 + src1->_23 * src2->_31;
+ tmp._22 = src1->_21 * src2->_12 + src1->_22 * src2->_22 + src1->_23 * src2->_32;
+ tmp._23 = src1->_21 * src2->_13 + src1->_22 * src2->_23 + src1->_23 * src2->_33;
+ tmp._24 = 0.0f;
+
+ tmp._31 = src1->_31 * src2->_11 + src1->_32 * src2->_21 + src1->_33 * src2->_31;
+ tmp._32 = src1->_31 * src2->_12 + src1->_32 * src2->_22 + src1->_33 * src2->_32;
+ tmp._33 = src1->_31 * src2->_13 + src1->_32 * src2->_23 + src1->_33 * src2->_33;
+ tmp._34 = 0.0f;
+
+ tmp._41 = src1->_41 * src2->_11 + src1->_42 * src2->_21 + src1->_43 * src2->_31 + src2->_41;
+ tmp._42 = src1->_41 * src2->_12 + src1->_42 * src2->_22 + src1->_43 * src2->_32 + src2->_42;
+ tmp._43 = src1->_41 * src2->_13 + src1->_42 * src2->_23 + src1->_43 * src2->_33 + src2->_43;
+ tmp._44 = 1.0f;
+
+ *dst = tmp;
+}
+
+static void d3drm_matrix_set_rotation(struct d3drm_matrix *matrix, D3DVECTOR *axis, float theta)
+{
+ float sin_theta, cos_theta, vers_theta;
+
+ D3DRMVectorNormalize(axis);
+ sin_theta = sinf(theta);
+ cos_theta = cosf(theta);
+ vers_theta = 1.0f - cos_theta;
+
+ matrix->_11 = vers_theta * axis->u1.x * axis->u1.x + cos_theta;
+ matrix->_21 = vers_theta * axis->u1.x * axis->u2.y - sin_theta * axis->u3.z;
+ matrix->_31 = vers_theta * axis->u1.x * axis->u3.z + sin_theta * axis->u2.y;
+ matrix->_41 = 0.0f;
+
+ matrix->_12 = vers_theta * axis->u2.y * axis->u1.x + sin_theta * axis->u3.z;
+ matrix->_22 = vers_theta * axis->u2.y * axis->u2.y + cos_theta;
+ matrix->_32 = vers_theta * axis->u2.y * axis->u3.z - sin_theta * axis->u1.x;
+ matrix->_42 = 0.0f;
+
+ matrix->_13 = vers_theta * axis->u3.z * axis->u1.x - sin_theta * axis->u2.y;
+ matrix->_23 = vers_theta * axis->u3.z * axis->u2.y + sin_theta * axis->u1.x;
+ matrix->_33 = vers_theta * axis->u3.z * axis->u3.z + cos_theta;
+ matrix->_43 = 0.0f;
+
+ matrix->_14 = 0.0f;
+ matrix->_24 = 0.0f;
+ matrix->_34 = 0.0f;
+ matrix->_44 = 1.0f;
+}
+
+static void d3drm_vector_transform_affine(D3DVECTOR *dst, const D3DVECTOR *v, const struct d3drm_matrix *m)
+{
+ D3DVECTOR tmp;
+
+ tmp.u1.x = v->u1.x * m->_11 + v->u2.y * m->_21 + v->u3.z * m->_31 + m->_41;
+ tmp.u2.y = v->u1.x * m->_12 + v->u2.y * m->_22 + v->u3.z * m->_32 + m->_42;
+ tmp.u3.z = v->u1.x * m->_13 + v->u2.y * m->_23 + v->u3.z * m->_33 + m->_43;
+
+ *dst = tmp;
+}
+
static HRESULT WINAPI d3drm_frame_array_QueryInterface(IDirect3DRMFrameArray *iface, REFIID riid, void **out)
{
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
D3DRMCOMBINETYPE type, D3DRMMATRIX4D matrix)
{
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+ const struct d3drm_matrix *m = d3drm_matrix(matrix);
TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);
+ if (m->_14 != 0.0f || m->_24 != 0.0f || m->_34 != 0.0f || m->_44 != 1.0f)
+ return D3DRMERR_BADVALUE;
+
switch (type)
{
case D3DRMCOMBINE_REPLACE:
- memcpy(frame->transform, matrix, sizeof(D3DRMMATRIX4D));
+ frame->transform = *m;
break;
case D3DRMCOMBINE_BEFORE:
- FIXME("D3DRMCOMBINE_BEFORE not supported yet\n");
+ d3drm_matrix_multiply_affine(&frame->transform, m, &frame->transform);
break;
case D3DRMCOMBINE_AFTER:
- FIXME("D3DRMCOMBINE_AFTER not supported yet\n");
+ d3drm_matrix_multiply_affine(&frame->transform, &frame->transform, m);
break;
default:
- WARN("Unknown Combine Type %u\n", type);
+ FIXME("Unhandled type %#x.\n", type);
return D3DRMERR_BADVALUE;
}
static HRESULT WINAPI d3drm_frame3_AddTranslation(IDirect3DRMFrame3 *iface,
D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
- FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+ switch (type)
+ {
+ case D3DRMCOMBINE_REPLACE:
+ frame->transform = identity;
+ frame->transform._41 = x;
+ frame->transform._42 = y;
+ frame->transform._43 = z;
+ break;
+
+ case D3DRMCOMBINE_BEFORE:
+ frame->transform._41 += x * frame->transform._11 + y * frame->transform._21 + z * frame->transform._31;
+ frame->transform._42 += x * frame->transform._12 + y * frame->transform._22 + z * frame->transform._32;
+ frame->transform._43 += x * frame->transform._13 + y * frame->transform._23 + z * frame->transform._33;
+ break;
+
+ case D3DRMCOMBINE_AFTER:
+ frame->transform._41 += x;
+ frame->transform._42 += y;
+ frame->transform._43 += z;
+ break;
+
+ default:
+ FIXME("Unhandled type %#x.\n", type);
+ return D3DRMERR_BADVALUE;
+ }
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_AddTranslation(IDirect3DRMFrame2 *iface,
D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
- FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+ return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
}
static HRESULT WINAPI d3drm_frame1_AddTranslation(IDirect3DRMFrame *iface,
D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
- FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+ return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
}
static HRESULT WINAPI d3drm_frame3_AddScale(IDirect3DRMFrame3 *iface,
D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
{
- FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);
+
+ switch (type)
+ {
+ case D3DRMCOMBINE_REPLACE:
+ frame->transform = identity;
+ frame->transform._11 = sx;
+ frame->transform._22 = sy;
+ frame->transform._33 = sz;
+ break;
+
+ case D3DRMCOMBINE_BEFORE:
+ frame->transform._11 *= sx;
+ frame->transform._12 *= sx;
+ frame->transform._13 *= sx;
+ frame->transform._21 *= sy;
+ frame->transform._22 *= sy;
+ frame->transform._23 *= sy;
+ frame->transform._31 *= sz;
+ frame->transform._32 *= sz;
+ frame->transform._33 *= sz;
+ break;
+
+ case D3DRMCOMBINE_AFTER:
+ frame->transform._11 *= sx;
+ frame->transform._12 *= sy;
+ frame->transform._13 *= sz;
+ frame->transform._21 *= sx;
+ frame->transform._22 *= sy;
+ frame->transform._23 *= sz;
+ frame->transform._31 *= sx;
+ frame->transform._32 *= sy;
+ frame->transform._33 *= sz;
+ frame->transform._41 *= sx;
+ frame->transform._42 *= sy;
+ frame->transform._43 *= sz;
+ break;
+
+ default:
+ FIXME("Unhandled type %#x.\n", type);
+ return D3DRMERR_BADVALUE;
+ }
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_AddScale(IDirect3DRMFrame2 *iface,
D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
{
- FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);
+
+ return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz);
}
static HRESULT WINAPI d3drm_frame1_AddScale(IDirect3DRMFrame *iface,
D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
{
- FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);
+
+ return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz);
}
static HRESULT WINAPI d3drm_frame3_AddRotation(IDirect3DRMFrame3 *iface,
D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
- FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n",
- iface, type, x, y, z, theta);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+ struct d3drm_matrix m;
+ D3DVECTOR axis;
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);
+
+ axis.u1.x = x;
+ axis.u2.y = y;
+ axis.u3.z = z;
+
+ switch (type)
+ {
+ case D3DRMCOMBINE_REPLACE:
+ d3drm_matrix_set_rotation(&frame->transform, &axis, theta);
+ break;
+
+ case D3DRMCOMBINE_BEFORE:
+ d3drm_matrix_set_rotation(&m, &axis, theta);
+ d3drm_matrix_multiply_affine(&frame->transform, &m, &frame->transform);
+ break;
+
+ case D3DRMCOMBINE_AFTER:
+ d3drm_matrix_set_rotation(&m, &axis, theta);
+ d3drm_matrix_multiply_affine(&frame->transform, &frame->transform, &m);
+ break;
+
+ default:
+ FIXME("Unhandled type %#x.\n", type);
+ return D3DRMERR_BADVALUE;
+ }
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_AddRotation(IDirect3DRMFrame2 *iface,
D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
- FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", iface, type, x, y, z, theta);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);
+
+ return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta);
}
static HRESULT WINAPI d3drm_frame1_AddRotation(IDirect3DRMFrame *iface,
D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
- FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", iface, type, x, y, z, theta);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);
+
+ return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta);
}
static HRESULT WINAPI d3drm_frame3_AddVisual(IDirect3DRMFrame3 *iface, IUnknown *visual)
IDirect3DRMFrame3 *reference, D3DRMMATRIX4D matrix)
{
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
+ struct d3drm_matrix *m = d3drm_matrix(matrix);
TRACE("iface %p, reference %p, matrix %p.\n", iface, reference, matrix);
if (reference)
- FIXME("Specifying a frame as the root of the scene different from the current root frame is not supported yet\n");
+ FIXME("Ignoring reference frame %p.\n", reference);
- memcpy(matrix, frame->transform, sizeof(D3DRMMATRIX4D));
+ *m = frame->transform;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_GetTransform(IDirect3DRMFrame2 *iface, D3DRMMATRIX4D matrix)
{
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
+ struct d3drm_matrix *m = d3drm_matrix(matrix);
TRACE("iface %p, matrix %p.\n", iface, matrix);
- memcpy(matrix, frame->transform, sizeof(D3DRMMATRIX4D));
+ *m = frame->transform;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame3_Transform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
- FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+ d3drm_vector_transform_affine(d, s, &frame->transform);
+ while ((frame = frame->parent))
+ {
+ d3drm_vector_transform_affine(d, d, &frame->transform);
+ }
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_Transform(IDirect3DRMFrame2 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
- FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+ return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
}
static HRESULT WINAPI d3drm_frame1_Transform(IDirect3DRMFrame *iface, D3DVECTOR *d, D3DVECTOR *s)
{
- FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+ return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
}
static HRESULT WINAPI d3drm_frame2_AddMoveCallback2(IDirect3DRMFrame2 *iface,
d3drm_frame1_Transform,
};
-static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
+struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
{
if (!iface)
return NULL;
d3drm_object_init(&object->obj, classname);
- memcpy(object->transform, identity, sizeof(D3DRMMATRIX4D));
+ object->transform = identity;
if (parent_frame)
{
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include "d3drm_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
if (FAILED(hr = IDirect3DRMFrame_GetScene(viewport->camera, &root_frame)))
return hr;
color = IDirect3DRMFrame_GetSceneBackground(root_frame);
+ IDirect3DRMFrame_Release(root_frame);
memset(&mat, 0, sizeof(mat));
mat.dwSize = sizeof(mat);
viewport->material = material;
viewport->device = device_obj;
+ viewport->clip.left = -0.5f;
+ viewport->clip.top = 0.5f;
+ viewport->clip.right = 0.5f;
+ viewport->clip.bottom = -0.5f;
+ viewport->clip.front = 1.0f;
+ viewport->clip.back = 100.0f;
+
cleanup:
if (FAILED(hr))
TRACE("iface %p, front %.8e.\n", iface, front);
- viewport->front = front;
+ if (!viewport->d3d_viewport)
+ return D3DRMERR_BADOBJECT;
+
+ if (front <= 0.0f)
+ return D3DRMERR_BADVALUE;
+
+ viewport->clip.front = front;
return D3DRM_OK;
}
TRACE("iface %p, back %.8e.\n", iface, back);
- viewport->back = back;
+ if (!viewport->d3d_viewport)
+ return D3DRMERR_BADOBJECT;
+
+ if (back <= viewport->clip.front)
+ return D3DRMERR_BADVALUE;
+
+ viewport->clip.back = back;
return D3DRM_OK;
}
TRACE("iface %p, field %.8e.\n", iface, field);
- viewport->field = field;
+ if (!viewport->d3d_viewport)
+ return D3DRMERR_BADOBJECT;
+
+ if (field <= 0.0f)
+ return D3DRMERR_BADVALUE;
+
+ viewport->clip.left = -field;
+ viewport->clip.right = field;
+ viewport->clip.bottom = -field;
+ viewport->clip.top = field;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera)
{
- FIXME("iface %p, camera %p stub!\n", iface, camera);
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+ struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame3(camera);
- return E_NOTIMPL;
+ TRACE("iface %p, camera %p.\n", iface, camera);
+
+ if (!camera || !viewport->camera)
+ return D3DRMERR_BADOBJECT;
+
+ IDirect3DRMFrame_AddRef(&frame->IDirect3DRMFrame_iface);
+ IDirect3DRMFrame_Release(viewport->camera);
+ viewport->camera = &frame->IDirect3DRMFrame_iface;
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport1_SetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame *camera)
{
- FIXME("iface %p, camera %p stub!\n", iface, camera);
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+ struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
- return E_NOTIMPL;
+ TRACE("iface %p, camera %p.\n", iface, camera);
+
+ return d3drm_viewport2_SetCamera(&viewport->IDirect3DRMViewport2_iface,
+ frame ? &frame->IDirect3DRMFrame3_iface : NULL);
}
static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type)
static HRESULT WINAPI d3drm_viewport2_SetPlane(IDirect3DRMViewport2 *iface,
D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
{
- FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n",
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+
+ TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n",
iface, left, right, bottom, top);
- return E_NOTIMPL;
+ if (!viewport->d3d_viewport)
+ return D3DRMERR_BADOBJECT;
+
+ viewport->clip.left = left;
+ viewport->clip.right = right;
+ viewport->clip.bottom = bottom;
+ viewport->clip.top = top;
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface,
D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
{
- FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n",
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+
+ TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n",
iface, left, right, bottom, top);
- return E_NOTIMPL;
+ return d3drm_viewport2_SetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
}
static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera)
{
- FIXME("iface %p, camera %p stub!\n", iface, camera);
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, camera %p.\n", iface, camera);
+
+ if (!camera)
+ return D3DRMERR_BADVALUE;
+
+ if (!viewport->camera)
+ return D3DRMERR_BADOBJECT;
+
+ return IDirect3DRMFrame_QueryInterface(viewport->camera, &IID_IDirect3DRMFrame3, (void **)camera);
}
static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame **camera)
{
- FIXME("iface %p, camera %p stub!\n", iface, camera);
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+ struct d3drm_frame *camera_impl;
+ IDirect3DRMFrame3 *camera3;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("iface %p, camera %p.\n", iface, camera);
+
+ if (!camera)
+ return D3DRMERR_BADVALUE;
+
+ if (FAILED(hr = d3drm_viewport2_GetCamera(&viewport->IDirect3DRMViewport2_iface, &camera3)))
+ return hr;
+
+ camera_impl = unsafe_impl_from_IDirect3DRMFrame3(camera3);
+ *camera = &camera_impl->IDirect3DRMFrame_iface;
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
TRACE("iface %p, device %p.\n", iface, device);
+ if (!device)
+ return D3DRMERR_BADVALUE;
+
if (!viewport->device)
return D3DRMERR_BADOBJECT;
TRACE("iface %p, device %p.\n\n", iface, device);
+ if (!device)
+ return D3DRMERR_BADVALUE;
+
if (!viewport->device)
return D3DRMERR_BADOBJECT;
static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface,
D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
{
- FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
+
+ TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
iface, left, right, bottom, top);
- return E_NOTIMPL;
+ if (!viewport->d3d_viewport)
+ return D3DRMERR_BADOBJECT;
+
+ *left = viewport->clip.left;
+ *right = viewport->clip.right;
+ *bottom = viewport->clip.bottom;
+ *top = viewport->clip.top;
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport1_GetPlane(IDirect3DRMViewport *iface,
D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
{
- FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
+ struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
+
+ TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
iface, left, right, bottom, top);
- return E_NOTIMPL;
+ return d3drm_viewport2_GetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
}
static HRESULT WINAPI d3drm_viewport2_Pick(IDirect3DRMViewport2 *iface,
TRACE("iface %p.\n", iface);
- return viewport->field;
+ if (!viewport->d3d_viewport)
+ return -1.0f;
+
+ return (viewport->clip.right - viewport->clip.left
+ + viewport->clip.top - viewport->clip.bottom) / 4.0f;
}
static D3DVALUE WINAPI d3drm_viewport1_GetField(IDirect3DRMViewport *iface)
TRACE("iface %p.\n", iface);
- return viewport->back;
+ if (!viewport->d3d_viewport)
+ return -1.0f;
+
+ return viewport->clip.back;
}
static D3DVALUE WINAPI d3drm_viewport1_GetBack(IDirect3DRMViewport *iface)
TRACE("iface %p.\n", iface);
- return viewport->front;
+ if (!viewport->d3d_viewport)
+ return -1.0f;
+
+ return viewport->clip.front;
}
static D3DVALUE WINAPI d3drm_viewport1_GetFront(IDirect3DRMViewport *iface)
TRACE("iface %p, viewport %p.\n", iface, viewport);
+ if (!viewport)
+ return D3DRMERR_BADVALUE;
+
if (!viewport_object->d3d_viewport)
return D3DRMERR_BADOBJECT;