viewport.c 34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * Implementation of IDirect3DRMViewport Interface
 *
 * Copyright 2012 André Hentschel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "d3drm_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(d3drm);

25
static inline struct d3drm_viewport *impl_from_IDirect3DRMViewport(IDirect3DRMViewport *iface)
26
{
27
    return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport_iface);
28 29
}

30
static inline struct d3drm_viewport *impl_from_IDirect3DRMViewport2(IDirect3DRMViewport2 *iface)
31
{
32
    return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport2_iface);
33 34
}

35 36
static inline void d3drm_normalize_d3d_color(D3DCOLORVALUE *color_value, D3DCOLOR color)
{
37 38 39 40
    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;
41 42 43 44 45 46 47 48 49 50 51 52
}

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);
53
    IDirect3DRMFrame_Release(root_frame);
54 55 56

    memset(&mat, 0, sizeof(mat));
    mat.dwSize = sizeof(mat);
57
    d3drm_normalize_d3d_color(&mat.u.diffuse, color);
58 59 60 61

    return IDirect3DMaterial_SetMaterial(viewport->material, &mat);
}

62 63
static void d3drm_viewport_destroy(struct d3drm_viewport *viewport)
{
64
    TRACE("viewport %p releasing attached interfaces.\n", viewport);
65 66

    d3drm_object_cleanup((IDirect3DRMObject *)&viewport->IDirect3DRMViewport_iface, &viewport->obj);
67 68 69 70 71 72 73 74 75

    if (viewport->d3d_viewport)
    {
        IDirect3DViewport_Release(viewport->d3d_viewport);
        IDirect3DMaterial_Release(viewport->material);
        IDirect3DRMFrame_Release(viewport->camera);
        IDirect3DRM_Release(viewport->d3drm);
    }

76
    heap_free(viewport);
77 78
}

79 80 81 82 83 84
static HRESULT WINAPI d3drm_viewport2_QueryInterface(IDirect3DRMViewport2 *iface, REFIID riid, void **out)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);

    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);

85
    if (IsEqualGUID(riid, &IID_IDirect3DRMViewport)
86
            || IsEqualGUID(riid, &IID_IDirect3DRMObject)
87
            || IsEqualGUID(riid, &IID_IUnknown))
88
    {
89
        *out = &viewport->IDirect3DRMViewport_iface;
90
    }
91
    else if (IsEqualGUID(riid, &IID_IDirect3DRMViewport2))
92
    {
93
        *out = &viewport->IDirect3DRMViewport2_iface;
94 95 96
    }
    else
    {
97
        *out = NULL;
98 99
        WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
        return CLASS_E_CLASSNOTAVAILABLE;
100 101
    }

102
    IUnknown_AddRef((IUnknown *)*out);
103
    return S_OK;
104 105
}

106
static HRESULT WINAPI d3drm_viewport1_QueryInterface(IDirect3DRMViewport *iface, REFIID riid, void **out)
107
{
108
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
109

110
    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
111

112
    return d3drm_viewport2_QueryInterface(&viewport->IDirect3DRMViewport2_iface, riid, out);
113 114
}

115
static ULONG WINAPI d3drm_viewport2_AddRef(IDirect3DRMViewport2 *iface)
116
{
117
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
118
    ULONG refcount = InterlockedIncrement(&viewport->obj.ref);
119

120
    TRACE("%p increasing refcount to %u.\n", iface, refcount);
121

122
    return refcount;
123 124
}

125
static ULONG WINAPI d3drm_viewport1_AddRef(IDirect3DRMViewport *iface)
126
{
127
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
128 129 130

    TRACE("iface %p.\n", iface);

131
    return d3drm_viewport2_AddRef(&viewport->IDirect3DRMViewport2_iface);
132 133
}

134
static ULONG WINAPI d3drm_viewport2_Release(IDirect3DRMViewport2 *iface)
135
{
136
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
137
    ULONG refcount = InterlockedDecrement(&viewport->obj.ref);
138

139
    TRACE("%p decreasing refcount to %u.\n", iface, refcount);
140

141
    if (!refcount)
142
        d3drm_viewport_destroy(viewport);
143

144
    return refcount;
145 146
}

147 148 149 150 151 152 153 154 155
static ULONG WINAPI d3drm_viewport1_Release(IDirect3DRMViewport *iface)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_viewport2_Release(&viewport->IDirect3DRMViewport2_iface);
}

156
static HRESULT WINAPI d3drm_viewport2_Clone(IDirect3DRMViewport2 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
157
        IUnknown *outer, REFIID iid, void **out)
158
{
Henri Verbeet's avatar
Henri Verbeet committed
159
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
160 161 162 163

    return E_NOTIMPL;
}

164 165
static HRESULT WINAPI d3drm_viewport1_Clone(IDirect3DRMViewport *iface,
        IUnknown *outer, REFIID iid, void **out)
166
{
167
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
168

169
    return E_NOTIMPL;
170 171
}

172
static HRESULT WINAPI d3drm_viewport2_AddDestroyCallback(IDirect3DRMViewport2 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
173
        D3DRMOBJECTCALLBACK cb, void *ctx)
174
{
175
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
176

177 178
    TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);

179
    return d3drm_object_add_destroy_callback(&viewport->obj, cb, ctx);
180 181
}

182 183
static HRESULT WINAPI d3drm_viewport1_AddDestroyCallback(IDirect3DRMViewport *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
184
{
185
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
186

187
    TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
188

189
    return d3drm_viewport2_AddDestroyCallback(&viewport->IDirect3DRMViewport2_iface, cb, ctx);
190 191
}

192 193
static HRESULT WINAPI d3drm_viewport2_DeleteDestroyCallback(IDirect3DRMViewport2 *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
194
{
195
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
196

197
    TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
198

199
    return d3drm_object_delete_destroy_callback(&viewport->obj, cb, ctx);
200 201
}

202 203
static HRESULT WINAPI d3drm_viewport1_DeleteDestroyCallback(IDirect3DRMViewport *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
204
{
205
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
206

207
    TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
208

209
    return d3drm_viewport2_DeleteDestroyCallback(&viewport->IDirect3DRMViewport2_iface, cb, ctx);
210 211
}

212
static HRESULT WINAPI d3drm_viewport2_SetAppData(IDirect3DRMViewport2 *iface, DWORD data)
213
{
214
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
215

216
    TRACE("iface %p, data %#x\n", iface, data);
217

218 219
    viewport->obj.appdata = data;
    return S_OK;
220 221
}

222
static HRESULT WINAPI d3drm_viewport1_SetAppData(IDirect3DRMViewport *iface, DWORD data)
223
{
224
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
225

226
    TRACE("iface %p, data %#x\n", iface, data);
227

228
    return d3drm_viewport2_SetAppData(&viewport->IDirect3DRMViewport2_iface, data);
229 230
}

231
static DWORD WINAPI d3drm_viewport2_GetAppData(IDirect3DRMViewport2 *iface)
232
{
233
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
234

235
    TRACE("iface %p\n", iface);
236

237
    return viewport->obj.appdata;
238 239
}

240
static DWORD WINAPI d3drm_viewport1_GetAppData(IDirect3DRMViewport *iface)
241
{
242
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
243

244
    TRACE("iface %p.\n", iface);
245

246
    return d3drm_viewport2_GetAppData(&viewport->IDirect3DRMViewport2_iface);
247 248
}

249
static HRESULT WINAPI d3drm_viewport2_SetName(IDirect3DRMViewport2 *iface, const char *name)
250
{
251
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
252

253 254 255
    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_object_set_name(&viewport->obj, name);
256 257
}

258
static HRESULT WINAPI d3drm_viewport1_SetName(IDirect3DRMViewport *iface, const char *name)
259
{
260
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
261

262 263 264
    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_viewport2_SetName(&viewport->IDirect3DRMViewport2_iface, name);
265 266
}

267
static HRESULT WINAPI d3drm_viewport2_GetName(IDirect3DRMViewport2 *iface, DWORD *size, char *name)
268
{
269
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
270

271 272 273
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_object_get_name(&viewport->obj, size, name);
274 275
}

276
static HRESULT WINAPI d3drm_viewport1_GetName(IDirect3DRMViewport *iface, DWORD *size, char *name)
277
{
278
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
279

280 281 282
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_viewport2_GetName(&viewport->IDirect3DRMViewport2_iface, size, name);
283 284
}

285
static HRESULT WINAPI d3drm_viewport2_GetClassName(IDirect3DRMViewport2 *iface, DWORD *size, char *name)
286
{
287
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
288

289
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);
290

291
    return d3drm_object_get_class_name(&viewport->obj, size, name);
292 293
}

294
static HRESULT WINAPI d3drm_viewport1_GetClassName(IDirect3DRMViewport *iface, DWORD *size, char *name)
295
{
296
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
297

298
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);
299

300
    return d3drm_viewport2_GetClassName(&viewport->IDirect3DRMViewport2_iface, size, name);
301 302
}

303 304
static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 *device,
        IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height)
305
{
306
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
307
    struct d3drm_device *device_obj = unsafe_impl_from_IDirect3DRMDevice3(device);
308 309 310 311 312 313 314 315 316
    D3DVIEWPORT vp;
    D3DVALUE scale;
    IDirect3D *d3d1 = NULL;
    IDirect3DDevice *d3d_device = NULL;
    IDirect3DMaterial *material = NULL;
    D3DMATERIALHANDLE hmat;
    HRESULT hr = D3DRM_OK;

    TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u.\n",
317
            iface, device, camera, x, y, width, height);
318

319 320 321
    if (!device_obj || !camera
            || width > device_obj->width
            || height > device_obj->height)
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
    {
        return D3DRMERR_BADOBJECT;
    }

    if (viewport->d3d_viewport)
        return D3DRMERR_BADOBJECT;

    IDirect3DRM_AddRef(viewport->d3drm);

    if (FAILED(hr = IDirect3DRMDevice3_GetDirect3DDevice(device, &d3d_device)))
        goto cleanup;

    if (FAILED(hr = IDirect3DDevice_GetDirect3D(d3d_device, &d3d1)))
        goto cleanup;

    if (FAILED(hr = IDirect3D_CreateViewport(d3d1, &viewport->d3d_viewport, NULL)))
        goto cleanup;

340 341 342
    if (FAILED(hr = IDirect3DDevice_AddViewport(d3d_device, viewport->d3d_viewport)))
        goto cleanup;

343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
    vp.dwSize = sizeof(vp);
    vp.dwWidth = width;
    vp.dwHeight = height;
    vp.dwX = x;
    vp.dwY = y;
    scale = width > height ? (float)width / 2.0f : (float)height / 2.0f;
    vp.dvScaleX = scale;
    vp.dvScaleY = scale;
    vp.dvMaxX = vp.dwWidth / (2.0f * vp.dvScaleX);
    vp.dvMaxY = vp.dwHeight / (2.0f * vp.dvScaleY);
    vp.dvMinZ = 0.0f;
    vp.dvMaxZ = 1.0f;

    if (FAILED(hr = IDirect3DViewport_SetViewport(viewport->d3d_viewport, &vp)))
        goto cleanup;

    if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(camera, &IID_IDirect3DRMFrame, (void **)&viewport->camera)))
        goto cleanup;

    if (FAILED(hr = IDirect3D_CreateMaterial(d3d1, &material, NULL)))
        goto cleanup;

    if (FAILED(hr = IDirect3DMaterial_GetHandle(material, d3d_device, &hmat)))
        goto cleanup;

    hr = IDirect3DViewport_SetBackground(viewport->d3d_viewport, hmat);
    viewport->material = material;
370
    viewport->device = device_obj;
371

372 373 374 375
    viewport->clip.left = -0.5f;
    viewport->clip.top = 0.5f;
    viewport->clip.right = 0.5f;
    viewport->clip.bottom = -0.5f;
376 377
    viewport->clip.front = 1.0f;
    viewport->clip.back = 100.0f;
378

379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
cleanup:

    if (FAILED(hr))
    {
        if (viewport->d3d_viewport)
        {
            IDirect3DViewport_Release(viewport->d3d_viewport);
            viewport->d3d_viewport = NULL;
        }
        if (viewport->camera)
            IDirect3DRMFrame_Release(viewport->camera);
        if (material)
            IDirect3DMaterial_Release(material);
        IDirect3DRM_Release(viewport->d3drm);
    }
    if (d3d_device)
        IDirect3DDevice_Release(d3d_device);
    if (d3d1)
        IDirect3D_Release(d3d1);

    return hr;
400 401
}

402 403
static HRESULT WINAPI d3drm_viewport1_Init(IDirect3DRMViewport *iface, IDirect3DRMDevice *device,
        IDirect3DRMFrame *camera, DWORD x, DWORD y, DWORD width, DWORD height)
404
{
405 406 407 408
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
    struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
    IDirect3DRMDevice3 *device3;
    HRESULT hr;
409

410 411 412 413 414 415 416 417 418 419 420 421 422 423
    TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u.\n",
          iface, device, camera, x, y, width, height);

    if (!device || !frame)
        return D3DRMERR_BADOBJECT;

    if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
        return hr;

    hr = d3drm_viewport2_Init(&viewport->IDirect3DRMViewport2_iface, device3, &frame->IDirect3DRMFrame3_iface,
            x, y, width, height);
    IDirect3DRMDevice3_Release(device3);

    return hr;
424 425
}

426
static HRESULT WINAPI d3drm_viewport2_Clear(IDirect3DRMViewport2 *iface, DWORD flags)
427
{
428 429 430 431 432 433 434 435 436
    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);

437 438 439
    clear_rect.u1.x1 = clear_rect.u2.y1 = 0;
    clear_rect.u3.x2 = viewport->device->width;
    clear_rect.u4.y2 = viewport->device->height;
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

    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;
460

461
    return D3DRM_OK;
462 463
}

464 465
static HRESULT WINAPI d3drm_viewport1_Clear(IDirect3DRMViewport *iface)
{
466
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
467

468 469 470
    TRACE("iface %p.\n", iface);

    return d3drm_viewport2_Clear(&viewport->IDirect3DRMViewport2_iface, D3DRMCLEAR_ALL);
471 472
}

473
static HRESULT WINAPI d3drm_viewport2_Render(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *frame)
474
{
475
    FIXME("iface %p, frame %p stub!\n", iface, frame);
476

477
    return D3DRM_OK;
478 479
}

480 481 482 483 484 485 486
static HRESULT WINAPI d3drm_viewport1_Render(IDirect3DRMViewport *iface, IDirect3DRMFrame *frame)
{
    FIXME("iface %p, frame %p stub!\n", iface, frame);

    return D3DRM_OK;
}

487
static HRESULT WINAPI d3drm_viewport2_SetFront(IDirect3DRMViewport2 *iface, D3DVALUE front)
488
{
489
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
490

491
    TRACE("iface %p, front %.8e.\n", iface, front);
492

493 494 495 496 497 498
    if (!viewport->d3d_viewport)
        return D3DRMERR_BADOBJECT;

    if (front <= 0.0f)
        return D3DRMERR_BADVALUE;

499
    viewport->clip.front = front;
500 501

    return D3DRM_OK;
502 503
}

504 505 506 507 508 509 510 511 512
static HRESULT WINAPI d3drm_viewport1_SetFront(IDirect3DRMViewport *iface, D3DVALUE front)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p, front %.8e.\n", iface, front);

    return d3drm_viewport2_SetFront(&viewport->IDirect3DRMViewport2_iface, front);
}

513
static HRESULT WINAPI d3drm_viewport2_SetBack(IDirect3DRMViewport2 *iface, D3DVALUE back)
514
{
515
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
516

517
    TRACE("iface %p, back %.8e.\n", iface, back);
518

519 520 521 522 523 524
    if (!viewport->d3d_viewport)
        return D3DRMERR_BADOBJECT;

    if (back <= viewport->clip.front)
        return D3DRMERR_BADVALUE;

525
    viewport->clip.back = back;
526 527

    return D3DRM_OK;
528 529
}

530 531 532 533 534 535 536 537 538
static HRESULT WINAPI d3drm_viewport1_SetBack(IDirect3DRMViewport *iface, D3DVALUE back)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p, back %.8e.\n", iface, back);

    return d3drm_viewport2_SetBack(&viewport->IDirect3DRMViewport2_iface, back);
}

539
static HRESULT WINAPI d3drm_viewport2_SetField(IDirect3DRMViewport2 *iface, D3DVALUE field)
540
{
541
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
542

543
    TRACE("iface %p, field %.8e.\n", iface, field);
544

545 546 547
    if (!viewport->d3d_viewport)
        return D3DRMERR_BADOBJECT;

548 549 550
    if (field <= 0.0f)
        return D3DRMERR_BADVALUE;

551 552 553 554
    viewport->clip.left = -field;
    viewport->clip.right = field;
    viewport->clip.bottom = -field;
    viewport->clip.top = field;
555 556

    return D3DRM_OK;
557 558
}

559 560 561 562 563 564 565 566 567
static HRESULT WINAPI d3drm_viewport1_SetField(IDirect3DRMViewport *iface, D3DVALUE field)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p, field %.8e.\n", iface, field);

    return d3drm_viewport2_SetField(&viewport->IDirect3DRMViewport2_iface, field);
}

568
static HRESULT WINAPI d3drm_viewport2_SetUniformScaling(IDirect3DRMViewport2 *iface, BOOL b)
569
{
570
    FIXME("iface %p, b %#x stub!\n", iface, b);
571 572 573 574

    return E_NOTIMPL;
}

575 576 577 578 579 580 581
static HRESULT WINAPI d3drm_viewport1_SetUniformScaling(IDirect3DRMViewport *iface, BOOL b)
{
    FIXME("iface %p, b %#x stub!\n", iface, b);

    return E_NOTIMPL;
}

582
static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera)
583
{
584 585
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
    struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame3(camera);
586

587 588 589 590 591 592 593 594 595 596
    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;
597 598
}

599 600
static HRESULT WINAPI d3drm_viewport1_SetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame *camera)
{
601 602
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
    struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
603

604 605 606 607
    TRACE("iface %p, camera %p.\n", iface, camera);

    return d3drm_viewport2_SetCamera(&viewport->IDirect3DRMViewport2_iface,
            frame ? &frame->IDirect3DRMFrame3_iface : NULL);
608 609
}

610
static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type)
611
{
612
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
613

614
    TRACE("iface %p, type %#x.\n", iface, type);
615

616 617 618
    if (!viewport->d3d_viewport)
        return D3DRMERR_BADOBJECT;

619
    viewport->projection = type;
620 621

    return D3DRM_OK;
622 623
}

624 625 626 627 628 629 630 631 632
static HRESULT WINAPI d3drm_viewport1_SetProjection(IDirect3DRMViewport *iface, D3DRMPROJECTIONTYPE type)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p, type %#x.\n", iface, type);

    return d3drm_viewport2_SetProjection(&viewport->IDirect3DRMViewport2_iface, type);
}

633
static HRESULT WINAPI d3drm_viewport2_Transform(IDirect3DRMViewport2 *iface, D3DRMVECTOR4D *d, D3DVECTOR *s)
634
{
635
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
636 637 638 639

    return E_NOTIMPL;
}

640 641 642 643 644 645 646
static HRESULT WINAPI d3drm_viewport1_Transform(IDirect3DRMViewport *iface, D3DRMVECTOR4D *d, D3DVECTOR *s)
{
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);

    return E_NOTIMPL;
}

647
static HRESULT WINAPI d3drm_viewport2_InverseTransform(IDirect3DRMViewport2 *iface, D3DVECTOR *d, D3DRMVECTOR4D *s)
648
{
649
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
650 651 652 653

    return E_NOTIMPL;
}

654 655 656 657 658 659 660
static HRESULT WINAPI d3drm_viewport1_InverseTransform(IDirect3DRMViewport *iface, D3DVECTOR *d, D3DRMVECTOR4D *s)
{
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);

    return E_NOTIMPL;
}

661 662
static HRESULT WINAPI d3drm_viewport2_Configure(IDirect3DRMViewport2 *iface,
        LONG x, LONG y, DWORD width, DWORD height)
663
{
664
    FIXME("iface %p, x %d, y %d, width %u, height %u stub!\n", iface, x, y, width, height);
665 666 667 668

    return E_NOTIMPL;
}

669 670 671 672 673 674 675 676
static HRESULT WINAPI d3drm_viewport1_Configure(IDirect3DRMViewport *iface,
        LONG x, LONG y, DWORD width, DWORD height)
{
    FIXME("iface %p, x %d, y %d, width %u, height %u stub!\n", iface, x, y, width, height);

    return E_NOTIMPL;
}

677 678
static HRESULT WINAPI d3drm_viewport2_ForceUpdate(IDirect3DRMViewport2* iface,
        DWORD x1, DWORD y1, DWORD x2, DWORD y2)
679
{
680
    FIXME("iface %p, x1 %u, y1 %u, x2 %u, y2 %u stub!\n", iface, x1, y1, x2, y2);
681 682 683 684

    return E_NOTIMPL;
}

685 686 687 688 689 690 691 692
static HRESULT WINAPI d3drm_viewport1_ForceUpdate(IDirect3DRMViewport *iface,
        DWORD x1, DWORD y1, DWORD x2, DWORD y2)
{
    FIXME("iface %p, x1 %u, y1 %u, x2 %u, y2 %u stub!\n", iface, x1, y1, x2, y2);

    return E_NOTIMPL;
}

693 694
static HRESULT WINAPI d3drm_viewport2_SetPlane(IDirect3DRMViewport2 *iface,
        D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
695
{
696 697 698
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);

    TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n",
699
            iface, left, right, bottom, top);
700

701 702 703 704 705 706 707 708 709
    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;
710 711
}

712 713 714
static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface,
        D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
{
715 716 717
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n",
718 719
            iface, left, right, bottom, top);

720
    return d3drm_viewport2_SetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
721 722
}

723
static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera)
724
{
725
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
726

727 728 729 730 731 732 733 734 735
    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);
736 737
}

738 739
static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame **camera)
{
740 741 742 743
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
    struct d3drm_frame *camera_impl;
    IDirect3DRMFrame3 *camera3;
    HRESULT hr;
744

745 746 747 748 749 750 751 752 753 754 755 756
    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;
757 758
}

759
static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
760
{
761
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
762

763 764
    TRACE("iface %p, device %p.\n", iface, device);

765 766 767
    if (!device)
        return D3DRMERR_BADVALUE;

768 769 770 771 772 773 774
    if (!viewport->device)
        return D3DRMERR_BADOBJECT;

    *device = &viewport->device->IDirect3DRMDevice3_iface;
    IDirect3DRMDevice3_AddRef(*device);

    return D3DRM_OK;
775 776
}

777 778
static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDirect3DRMDevice **device)
{
779
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
780

781 782
    TRACE("iface %p, device %p.\n\n", iface, device);

783 784 785
    if (!device)
        return D3DRMERR_BADVALUE;

786 787 788 789 790 791 792
    if (!viewport->device)
        return D3DRMERR_BADOBJECT;

    *device = &viewport->device->IDirect3DRMDevice_iface;
    IDirect3DRMDevice_AddRef(*device);

    return D3DRM_OK;
793 794
}

795 796
static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface,
        D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
797
{
798 799 800
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);

    TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
801
            iface, left, right, bottom, top);
802

803 804 805 806 807 808 809 810 811
    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;
812 813
}

814 815 816
static HRESULT WINAPI d3drm_viewport1_GetPlane(IDirect3DRMViewport *iface,
        D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
{
817 818 819
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
820 821
            iface, left, right, bottom, top);

822
    return d3drm_viewport2_GetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
823 824
}

825
static HRESULT WINAPI d3drm_viewport2_Pick(IDirect3DRMViewport2 *iface,
826
        LONG x, LONG y, IDirect3DRMPickedArray **visuals)
827
{
828
    FIXME("iface %p, x %d, y %d, visuals %p stub!\n", iface, x, y, visuals);
829 830 831 832

    return E_NOTIMPL;
}

833 834 835 836 837 838 839 840
static HRESULT WINAPI d3drm_viewport1_Pick(IDirect3DRMViewport *iface,
        LONG x, LONG y, IDirect3DRMPickedArray **visuals)
{
    FIXME("iface %p, x %d, y %d, visuals %p stub!\n", iface, x, y, visuals);

    return E_NOTIMPL;
}

841
static BOOL WINAPI d3drm_viewport2_GetUniformScaling(IDirect3DRMViewport2 *iface)
842
{
843
    FIXME("iface %p stub!\n", iface);
844

845
    return FALSE;
846 847
}

848 849 850 851 852 853 854
static BOOL WINAPI d3drm_viewport1_GetUniformScaling(IDirect3DRMViewport *iface)
{
    FIXME("iface %p stub!\n", iface);

    return FALSE;
}

855
static LONG WINAPI d3drm_viewport2_GetX(IDirect3DRMViewport2 *iface)
856
{
857
    FIXME("iface %p stub!\n", iface);
858 859 860 861

    return E_NOTIMPL;
}

862 863 864 865 866 867 868
static LONG WINAPI d3drm_viewport1_GetX(IDirect3DRMViewport *iface)
{
    FIXME("iface %p stub!\n", iface);

    return E_NOTIMPL;
}

869
static LONG WINAPI d3drm_viewport2_GetY(IDirect3DRMViewport2 *iface)
870
{
871
    FIXME("iface %p stub!\n", iface);
872 873 874 875

    return E_NOTIMPL;
}

876 877 878 879 880 881 882
static LONG WINAPI d3drm_viewport1_GetY(IDirect3DRMViewport *iface)
{
    FIXME("iface %p stub!\n", iface);

    return E_NOTIMPL;
}

883
static DWORD WINAPI d3drm_viewport2_GetWidth(IDirect3DRMViewport2 *iface)
884
{
885
    FIXME("iface %p stub!\n", iface);
886 887 888 889

    return E_NOTIMPL;
}

890 891 892 893 894 895 896
static DWORD WINAPI d3drm_viewport1_GetWidth(IDirect3DRMViewport *iface)
{
    FIXME("iface %p stub!\n", iface);

    return E_NOTIMPL;
}

897
static DWORD WINAPI d3drm_viewport2_GetHeight(IDirect3DRMViewport2 *iface)
898
{
899
    FIXME("iface %p stub!\n", iface);
900 901 902 903

    return E_NOTIMPL;
}

904 905 906 907 908 909 910
static DWORD WINAPI d3drm_viewport1_GetHeight(IDirect3DRMViewport *iface)
{
    FIXME("iface %p stub!\n", iface);

    return E_NOTIMPL;
}

911
static D3DVALUE WINAPI d3drm_viewport2_GetField(IDirect3DRMViewport2 *iface)
912
{
913
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
914

915
    TRACE("iface %p.\n", iface);
916

917 918 919 920 921
    if (!viewport->d3d_viewport)
        return -1.0f;

    return (viewport->clip.right - viewport->clip.left
            + viewport->clip.top - viewport->clip.bottom) / 4.0f;
922 923
}

924 925 926 927 928 929 930 931 932
static D3DVALUE WINAPI d3drm_viewport1_GetField(IDirect3DRMViewport *iface)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_viewport2_GetField(&viewport->IDirect3DRMViewport2_iface);
}

933
static D3DVALUE WINAPI d3drm_viewport2_GetBack(IDirect3DRMViewport2 *iface)
934
{
935
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
936

937
    TRACE("iface %p.\n", iface);
938

939 940 941
    if (!viewport->d3d_viewport)
        return -1.0f;

942
    return viewport->clip.back;
943 944
}

945 946 947 948 949 950 951 952 953
static D3DVALUE WINAPI d3drm_viewport1_GetBack(IDirect3DRMViewport *iface)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_viewport2_GetBack(&viewport->IDirect3DRMViewport2_iface);
}

954
static D3DVALUE WINAPI d3drm_viewport2_GetFront(IDirect3DRMViewport2 *iface)
955
{
956
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
957

958
    TRACE("iface %p.\n", iface);
959

960 961 962
    if (!viewport->d3d_viewport)
        return -1.0f;

963
    return viewport->clip.front;
964 965
}

966 967 968 969 970 971 972 973 974
static D3DVALUE WINAPI d3drm_viewport1_GetFront(IDirect3DRMViewport *iface)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_viewport2_GetFront(&viewport->IDirect3DRMViewport2_iface);
}

975
static D3DRMPROJECTIONTYPE WINAPI d3drm_viewport2_GetProjection(IDirect3DRMViewport2 *iface)
976
{
977
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
978

979
    TRACE("iface %p.\n", iface);
980

981 982 983
    if (!viewport->d3d_viewport)
        return ~0u;

984
    return viewport->projection;
985 986
}

987 988 989 990 991 992 993 994 995
static D3DRMPROJECTIONTYPE WINAPI d3drm_viewport1_GetProjection(IDirect3DRMViewport *iface)
{
    struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_viewport2_GetProjection(&viewport->IDirect3DRMViewport2_iface);
}

996
static HRESULT WINAPI d3drm_viewport2_GetDirect3DViewport(IDirect3DRMViewport2 *iface,
997
        IDirect3DViewport **viewport)
998
{
999
    struct d3drm_viewport *viewport_object = impl_from_IDirect3DRMViewport2(iface);
1000

1001 1002
    TRACE("iface %p, viewport %p.\n", iface, viewport);

1003 1004 1005
    if (!viewport)
        return D3DRMERR_BADVALUE;

1006 1007 1008 1009 1010 1011 1012
    if (!viewport_object->d3d_viewport)
        return D3DRMERR_BADOBJECT;

    *viewport = viewport_object->d3d_viewport;
    IDirect3DViewport_AddRef(*viewport);

    return D3DRM_OK;
1013 1014
}

1015 1016 1017
static HRESULT WINAPI d3drm_viewport1_GetDirect3DViewport(IDirect3DRMViewport *iface,
        IDirect3DViewport **viewport)
{
1018
    struct d3drm_viewport *viewport_object = impl_from_IDirect3DRMViewport(iface);
1019

1020 1021 1022
    TRACE("iface %p, viewport %p.\n", iface, viewport);

    return d3drm_viewport2_GetDirect3DViewport(&viewport_object->IDirect3DRMViewport2_iface, viewport);
1023 1024
}

1025 1026
static HRESULT WINAPI d3drm_viewport2_TransformVectors(IDirect3DRMViewport2 *iface,
        DWORD vector_count, D3DRMVECTOR4D *dst, D3DVECTOR *src)
1027
{
1028
    FIXME("iface %p, vector_count %u, dst %p, src %p stub!\n", iface, vector_count, dst, src);
1029 1030 1031 1032

    return E_NOTIMPL;
}

1033 1034
static HRESULT WINAPI d3drm_viewport2_InverseTransformVectors(IDirect3DRMViewport2 *iface,
        DWORD vector_count, D3DVECTOR *dst, D3DRMVECTOR4D *src)
1035
{
1036
    FIXME("iface %p, vector_count %u, dst %p, src %p stub!\n", iface, vector_count, dst, src);
1037 1038 1039 1040

    return E_NOTIMPL;
}

1041
static const struct IDirect3DRMViewport2Vtbl d3drm_viewport2_vtbl =
1042
{
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
    d3drm_viewport2_QueryInterface,
    d3drm_viewport2_AddRef,
    d3drm_viewport2_Release,
    d3drm_viewport2_Clone,
    d3drm_viewport2_AddDestroyCallback,
    d3drm_viewport2_DeleteDestroyCallback,
    d3drm_viewport2_SetAppData,
    d3drm_viewport2_GetAppData,
    d3drm_viewport2_SetName,
    d3drm_viewport2_GetName,
    d3drm_viewport2_GetClassName,
    d3drm_viewport2_Init,
    d3drm_viewport2_Clear,
    d3drm_viewport2_Render,
    d3drm_viewport2_SetFront,
    d3drm_viewport2_SetBack,
    d3drm_viewport2_SetField,
    d3drm_viewport2_SetUniformScaling,
    d3drm_viewport2_SetCamera,
    d3drm_viewport2_SetProjection,
    d3drm_viewport2_Transform,
    d3drm_viewport2_InverseTransform,
    d3drm_viewport2_Configure,
    d3drm_viewport2_ForceUpdate,
    d3drm_viewport2_SetPlane,
    d3drm_viewport2_GetCamera,
    d3drm_viewport2_GetDevice,
    d3drm_viewport2_GetPlane,
    d3drm_viewport2_Pick,
    d3drm_viewport2_GetUniformScaling,
    d3drm_viewport2_GetX,
    d3drm_viewport2_GetY,
    d3drm_viewport2_GetWidth,
    d3drm_viewport2_GetHeight,
    d3drm_viewport2_GetField,
    d3drm_viewport2_GetBack,
    d3drm_viewport2_GetFront,
    d3drm_viewport2_GetProjection,
    d3drm_viewport2_GetDirect3DViewport,
    d3drm_viewport2_TransformVectors,
    d3drm_viewport2_InverseTransformVectors,
1084 1085
};

1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
static const struct IDirect3DRMViewportVtbl d3drm_viewport1_vtbl =
{
    d3drm_viewport1_QueryInterface,
    d3drm_viewport1_AddRef,
    d3drm_viewport1_Release,
    d3drm_viewport1_Clone,
    d3drm_viewport1_AddDestroyCallback,
    d3drm_viewport1_DeleteDestroyCallback,
    d3drm_viewport1_SetAppData,
    d3drm_viewport1_GetAppData,
    d3drm_viewport1_SetName,
    d3drm_viewport1_GetName,
    d3drm_viewport1_GetClassName,
    d3drm_viewport1_Init,
    d3drm_viewport1_Clear,
    d3drm_viewport1_Render,
    d3drm_viewport1_SetFront,
    d3drm_viewport1_SetBack,
    d3drm_viewport1_SetField,
    d3drm_viewport1_SetUniformScaling,
    d3drm_viewport1_SetCamera,
    d3drm_viewport1_SetProjection,
    d3drm_viewport1_Transform,
    d3drm_viewport1_InverseTransform,
    d3drm_viewport1_Configure,
    d3drm_viewport1_ForceUpdate,
    d3drm_viewport1_SetPlane,
    d3drm_viewport1_GetCamera,
    d3drm_viewport1_GetDevice,
    d3drm_viewport1_GetPlane,
    d3drm_viewport1_Pick,
    d3drm_viewport1_GetUniformScaling,
    d3drm_viewport1_GetX,
    d3drm_viewport1_GetY,
    d3drm_viewport1_GetWidth,
    d3drm_viewport1_GetHeight,
    d3drm_viewport1_GetField,
    d3drm_viewport1_GetBack,
    d3drm_viewport1_GetFront,
    d3drm_viewport1_GetProjection,
    d3drm_viewport1_GetDirect3DViewport,
};

1129
HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm)
1130
{
1131
    static const char classname[] = "Viewport";
1132
    struct d3drm_viewport *object;
1133

1134
    TRACE("viewport %p, d3drm %p.\n", viewport, d3drm);
1135

1136
    if (!(object = heap_alloc_zero(sizeof(*object))))
1137 1138
        return E_OUTOFMEMORY;

1139 1140
    object->IDirect3DRMViewport_iface.lpVtbl = &d3drm_viewport1_vtbl;
    object->IDirect3DRMViewport2_iface.lpVtbl = &d3drm_viewport2_vtbl;
1141
    object->d3drm = d3drm;
1142
    d3drm_object_init(&object->obj, classname);
1143

1144
    *viewport = object;
1145 1146 1147

    return S_OK;
}