ReactOS  0.4.14-dev-115-g4576127
d3drm.c File Reference
#include <limits.h>
#include <d3d.h>
#include <initguid.h>
#include <d3drm.h>
#include <d3drmwin.h>
#include "wine/test.h"
Include dependency graph for d3drm.c:

Go to the source code of this file.

Classes

struct  destroy_context
 
struct  callback_order
 
struct  qi_test
 

Macros

#define COBJMACROS
 
#define CHECK_REFCOUNT(obj, rc)
 
#define check_vector(a, b, c, d, e)   check_vector_(__LINE__, a, b, c, d, e)
 
#define vector_eq(a, b)   vector_eq_(__LINE__, a, b)
 
#define test_class_name(a, b)   test_class_name_(__LINE__, a, b)
 
#define test_object_name(a)   test_object_name_(__LINE__, a)
 

Functions

static ULONG get_refcount (IUnknown *object)
 
static BOOL compare_float (float f, float g, unsigned int ulps)
 
static void check_vector_ (unsigned int line, const D3DVECTOR *v, float x, float y, float z, unsigned int ulps)
 
static void vector_eq_ (unsigned int line, const D3DVECTOR *left, const D3DVECTOR *right)
 
static HWND create_window (void)
 
static void test_class_name_ (unsigned int line, IDirect3DRMObject *object, const char *name)
 
static void test_object_name_ (unsigned int line, IDirect3DRMObject *object)
 
static void test_MeshBuilder (void)
 
static void test_MeshBuilder3 (void)
 
static void test_Mesh (void)
 
static void test_Face (void)
 
static void test_Frame (void)
 
static void CDECL destroy_callback (IDirect3DRMObject *obj, void *arg)
 
static void CDECL destroy_callback1 (IDirect3DRMObject *obj, void *arg)
 
static void test_destroy_callback (unsigned int test_idx, REFCLSID clsid, REFIID iid)
 
static void test_object (void)
 
static void test_Viewport (void)
 
static void test_Light (void)
 
static void test_Material2 (void)
 
static void test_Texture (void)
 
static void test_Device (void)
 
static void test_frame_transform (void)
 
static void __cdecl object_load_callback (IDirect3DRMObject *object, REFIID objectguid, void *arg)
 
static void test_d3drm_load (void)
 
static void __cdecl object_load_callback_frame (IDirect3DRMObject *object, REFIID object_guid, void *arg)
 
static void test_frame_mesh_materials (void)
 
static void test_qi (const char *test_name, IUnknown *base_iface, REFIID refcount_iid, const struct qi_test *tests, UINT entry_count)
 
static void test_d3drm_qi (void)
 
static void test_frame_qi (void)
 
static void test_device_qi (void)
 
static HRESULT CALLBACK surface_callback (IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
 
static void test_create_device_from_clipper1 (void)
 
static void test_create_device_from_clipper2 (void)
 
static void test_create_device_from_clipper3 (void)
 
static void test_create_device_from_surface1 (void)
 
static void test_create_device_from_surface2 (void)
 
static void test_create_device_from_surface3 (void)
 
static IDirect3DDevice * create_device1 (IDirectDraw *ddraw, HWND window, IDirectDrawSurface **ds)
 
static void test_create_device_from_d3d1 (void)
 
static IDirect3DDevice2 * create_device2 (IDirectDraw2 *ddraw, HWND window, IDirectDrawSurface **ds)
 
static void test_create_device_from_d3d2 (void)
 
static void test_create_device_from_d3d3 (void)
 
static charcreate_bitmap (unsigned int w, unsigned int h, BOOL palettized)
 
static void test_bitmap_data (unsigned int test_idx, const D3DRMIMAGE *img, BOOL upside_down, unsigned int w, unsigned int h, BOOL palettized)
 
static void test_load_texture (void)
 
static void test_texture_qi (void)
 
static void test_viewport_qi (void)
 
static D3DCOLOR get_surface_color (IDirectDrawSurface *surface, UINT x, UINT y)
 
static IDirect3DDevice2 * create_device2_without_ds (IDirectDraw2 *ddraw, HWND window)
 
static BOOL compare_color (D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
 
static void clear_depth_surface (IDirectDrawSurface *surface, DWORD value)
 
static void set_execute_data (IDirect3DExecuteBuffer *execute_buffer, UINT vertex_count, UINT offset, UINT len)
 
static void emit_set_ts (void **ptr, D3DTRANSFORMSTATETYPE state, DWORD value)
 
static void emit_set_rs (void **ptr, D3DRENDERSTATETYPE state, DWORD value)
 
static void emit_process_vertices (void **ptr, DWORD flags, WORD base_idx, DWORD vertex_count)
 
static void emit_tquad (void **ptr, WORD base_idx)
 
static void emit_end (void **ptr)
 
static void d3d_draw_quad1 (IDirect3DDevice *device, IDirect3DViewport *viewport)
 
static void test_viewport_clear1 (void)
 
static void draw_quad2 (IDirect3DDevice2 *device, IDirect3DViewport *viewport)
 
static void test_viewport_clear2 (void)
 
static void test_create_texture_from_surface (void)
 
static void test_animation (void)
 
static void test_animation_qi (void)
 
static void test_wrap (void)
 
static void test_wrap_qi (void)
 
 START_TEST (d3drm)
 

Variables

static D3DRMMATRIX4D identity
 
static char data_bad_version []
 
static char data_no_mesh []
 
static char data_ok []
 
static char data_full []
 
static char data_d3drm_load []
 
static char data_frame_mesh_materials []
 
struct callback_order corder [3]
 
struct callback_order d3drm_corder [3]
 
static int nb_objects = 0
 
static const GUIDrefiids []
 
IDirect3DRMMeshBuilder * mesh_builder = NULL
 
struct {
   int   vertex_count
 
   int   face_count
 
   int   vertex_per_face
 
   int   face_data_size
 
   DWORD   color
 
   float   power
 
   float   specular [3]
 
   float   emissive [3]
 
groups [3]
 

Macro Definition Documentation

◆ CHECK_REFCOUNT

#define CHECK_REFCOUNT (   obj,
  rc 
)
Value:
{ \
int rc_new = rc; \
int count = get_refcount( (IUnknown *)obj ); \
ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
}
GLuint GLuint GLsizei count
Definition: gl.h:1545
static ULONG get_refcount(IUnknown *object)
Definition: d3drm.c:39

Definition at line 32 of file d3drm.c.

◆ check_vector

#define check_vector (   a,
  b,
  c,
  d,
  e 
)    check_vector_(__LINE__, a, b, c, d, e)

Definition at line 61 of file d3drm.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file d3drm.c.

◆ test_class_name

#define test_class_name (   a,
  b 
)    test_class_name_(__LINE__, a, b)

Definition at line 95 of file d3drm.c.

◆ test_object_name

#define test_object_name (   a)    test_object_name_(__LINE__, a)

Definition at line 137 of file d3drm.c.

◆ vector_eq

#define vector_eq (   a,
  b 
)    vector_eq_(__LINE__, a, b)

Definition at line 72 of file d3drm.c.

Function Documentation

◆ check_vector_()

static void check_vector_ ( unsigned int  line,
const D3DVECTOR v,
float  x,
float  y,
float  z,
unsigned int  ulps 
)
static

Definition at line 62 of file d3drm.c.

63 {
64  BOOL ret = compare_float(U1(v)->x, x, ulps)
65  && compare_float(U2(v)->y, y, ulps)
66  && compare_float(U3(v)->z, z, ulps);
67 
68  ok_(__FILE__, line)(ret, "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
69  U1(v)->x, U2(v)->y, U3(v)->z, x, y, z);
70 }
#define U1(x)
Definition: test.h:172
#define U3(x)
Definition: wordpad.c:46
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static BOOL compare_float(float f, float g, unsigned int ulps)
Definition: d3drm.c:45
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble z
Definition: glext.h:5874
Definition: parser.c:48
int ret
#define U2(x)
Definition: wordpad.c:45
const GLdouble * v
Definition: gl.h:2040
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by vector_eq_().

◆ clear_depth_surface()

static void clear_depth_surface ( IDirectDrawSurface *  surface,
DWORD  value 
)
static

Definition at line 6086 of file d3drm.c.

6087 {
6088  HRESULT hr;
6089  DDBLTFX fx;
6090 
6091  memset(&fx, 0, sizeof(fx));
6092  fx.dwSize = sizeof(fx);
6093  U5(fx).dwFillDepth = value;
6094 
6095  hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
6096  ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
6097 }
#define U5(x)
Definition: test.h:176
HRESULT hr
Definition: shlfolder.c:183
smooth NULL
Definition: ftsmooth.c:416
#define DDBLT_WAIT
Definition: ddraw.h:569
LONG HRESULT
Definition: typedefs.h:77
GLfixed fx
Definition: tritemp.h:482
GLsizei const GLfloat * value
Definition: glext.h:6069
#define ok(value,...)
Definition: atltest.h:57
#define DDBLT_DEPTHFILL
Definition: ddraw.h:570
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_viewport_clear1(), and test_viewport_clear2().

◆ compare_color()

static BOOL compare_color ( D3DCOLOR  c1,
D3DCOLOR  c2,
BYTE  max_diff 
)
static

Definition at line 6074 of file d3drm.c.

6075 {
6076  if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6077  c1 >>= 8; c2 >>= 8;
6078  if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6079  c1 >>= 8; c2 >>= 8;
6080  if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6081  c1 >>= 8; c2 >>= 8;
6082  if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6083  return TRUE;
6084 }
#define TRUE
Definition: types.h:120

Referenced by test_viewport_clear1(), and test_viewport_clear2().

◆ compare_float()

static BOOL compare_float ( float  f,
float  g,
unsigned int  ulps 
)
static

Definition at line 45 of file d3drm.c.

46 {
47  int x = *(int *)&f;
48  int y = *(int *)&g;
49 
50  if (x < 0)
51  x = INT_MIN - x;
52  if (y < 0)
53  y = INT_MIN - y;
54 
55  if (abs(x - y) > ulps)
56  return FALSE;
57 
58  return TRUE;
59 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat f
Definition: glext.h:7540
#define INT_MIN
Definition: limits.h:39
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by check_vector_().

◆ create_bitmap()

static char* create_bitmap ( unsigned int  w,
unsigned int  h,
BOOL  palettized 
)
static

Definition at line 5373 of file d3drm.c.

5374 {
5375  unsigned int bpp = palettized ? 8 : 24;
5376  BITMAPFILEHEADER file_header;
5377  DWORD written, size, ret;
5378  unsigned char *buffer;
5379  char path[MAX_PATH];
5380  unsigned int i, j;
5381  BITMAPINFO *info;
5382  char *filename;
5383  HANDLE file;
5384 
5386  ok(ret, "Failed to get temporary file path.\n");
5388  ret = GetTempFileNameA(path, "d3d", 0, filename);
5389  ok(ret, "Failed to get filename.\n");
5391  ok(file != INVALID_HANDLE_VALUE, "Failed to open temporary file \"%s\".\n", filename);
5392 
5393  size = FIELD_OFFSET(BITMAPINFO, bmiColors[palettized ? 256 : 0]);
5394 
5395  memset(&file_header, 0, sizeof(file_header));
5396  file_header.bfType = 0x4d42; /* BM */
5397  file_header.bfOffBits = sizeof(file_header) + size;
5398  file_header.bfSize = file_header.bfOffBits + w * h * (bpp / 8);
5399  ret = WriteFile(file, &file_header, sizeof(file_header), &written, NULL);
5400  ok(ret && written == sizeof(file_header), "Failed to write file header.\n");
5401 
5403  info->bmiHeader.biSize = sizeof(info->bmiHeader);
5404  info->bmiHeader.biBitCount = bpp;
5405  info->bmiHeader.biPlanes = 1;
5406  info->bmiHeader.biWidth = w;
5407  info->bmiHeader.biHeight = h;
5408  info->bmiHeader.biCompression = BI_RGB;
5409  if (palettized)
5410  {
5411  for (i = 0; i < 256; ++i)
5412  {
5413  info->bmiColors[i].rgbBlue = i;
5414  info->bmiColors[i].rgbGreen = i;
5415  info->bmiColors[i].rgbRed = i;
5416  }
5417  }
5418  ret = WriteFile(file, info, size, &written, NULL);
5419  ok(ret && written == size, "Failed to write bitmap info.\n");
5420  HeapFree(GetProcessHeap(), 0, info);
5421 
5422  size = w * h * (bpp / 8);
5424  for (i = 0, j = 0; i < size;)
5425  {
5426  if (palettized)
5427  {
5428  buffer[i++] = j++;
5429  j %= 256;
5430  }
5431  else
5432  {
5433  buffer[i++] = j % 251;
5434  buffer[i++] = j % 239;
5435  buffer[i++] = j++ % 247;
5436  }
5437  }
5438  ret = WriteFile(file, buffer, size, &written, NULL);
5439  ok(ret && written == size, "Failed to write bitmap data.\n");
5441 
5442  CloseHandle(file);
5443 
5444  return filename;
5445 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:135
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
struct _test_info info[]
Definition: SetCursorPos.c:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD bpp
Definition: surface.c:181
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:34
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126

Referenced by test_load_texture(), and test_texture_qi().

◆ create_device1()

static IDirect3DDevice* create_device1 ( IDirectDraw *  ddraw,
HWND  window,
IDirectDrawSurface **  ds 
)
static

Definition at line 4415 of file d3drm.c.

4416 {
4417  static const DWORD z_depths[] = { 32, 24, 16 };
4418  IDirectDrawSurface *surface;
4419  IDirect3DDevice *device = NULL;
4420  DDSURFACEDESC surface_desc;
4421  unsigned int i;
4422  HRESULT hr;
4423  RECT rc;
4424 
4425  GetClientRect(window, &rc);
4426  hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
4427  ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
4428 
4429  memset(&surface_desc, 0, sizeof(surface_desc));
4430  surface_desc.dwSize = sizeof(surface_desc);
4431  surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4432  surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
4433  surface_desc.dwWidth = rc.right;
4434  surface_desc.dwHeight = rc.bottom;
4435 
4436  hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
4437  ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
4438 
4439  /* We used to use EnumDevices() for this, but it seems
4440  * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
4441  * relationship with reality. */
4442  for (i = 0; i < ARRAY_SIZE(z_depths); ++i)
4443  {
4444  memset(&surface_desc, 0, sizeof(surface_desc));
4445  surface_desc.dwSize = sizeof(surface_desc);
4446  surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
4447  surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
4448  U2(surface_desc).dwZBufferBitDepth = z_depths[i];
4449  surface_desc.dwWidth = rc.right;
4450  surface_desc.dwHeight = rc.bottom;
4451  if (FAILED(IDirectDraw_CreateSurface(ddraw, &surface_desc, ds, NULL)))
4452  continue;
4453 
4454  hr = IDirectDrawSurface_AddAttachedSurface(surface, *ds);
4455  ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
4456  if (FAILED(hr))
4457  {
4458  IDirectDrawSurface_Release(*ds);
4459  continue;
4460  }
4461 
4462  if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DHALDevice, (void **)&device)))
4463  break;
4464 
4465  IDirectDrawSurface_DeleteAttachedSurface(surface, 0, *ds);
4466  IDirectDrawSurface_Release(*ds);
4467  *ds = NULL;
4468  }
4469 
4470  IDirectDrawSurface_Release(surface);
4471  return device;
4472 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
HRESULT hr
Definition: shlfolder.c:183
#define ds
Definition: i386-dis.c:434
LONG right
Definition: windef.h:293
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DDSD_CAPS
Definition: ddraw.h:208
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:267
#define DDSD_HEIGHT
Definition: ddraw.h:209
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static IHTMLWindow2 * window
Definition: events.c:77
#define U2(x)
Definition: wordpad.c:45
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:213
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
LONG bottom
Definition: windef.h:294
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_create_device_from_d3d1().

◆ create_device2()

static IDirect3DDevice2* create_device2 ( IDirectDraw2 *  ddraw,
HWND  window,
IDirectDrawSurface **  ds 
)
static

Definition at line 4740 of file d3drm.c.

4741 {
4742  static const DWORD z_depths[] = { 32, 24, 16 };
4743  IDirectDrawSurface *surface;
4744  IDirect3DDevice2 *device = NULL;
4745  DDSURFACEDESC surface_desc;
4746  IDirect3D2 *d3d;
4747  unsigned int i;
4748  HRESULT hr;
4749  RECT rc;
4750 
4751  GetClientRect(window, &rc);
4752  hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
4753  ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
4754 
4755  memset(&surface_desc, 0, sizeof(surface_desc));
4756  surface_desc.dwSize = sizeof(surface_desc);
4757  surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4758  surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
4759  surface_desc.dwWidth = rc.right;
4760  surface_desc.dwHeight = rc.bottom;
4761 
4762  hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
4763  ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
4764 
4765  hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
4766  if (FAILED(hr))
4767  {
4768  IDirectDrawSurface_Release(surface);
4769  *ds = NULL;
4770  return NULL;
4771  }
4772 
4773  /* We used to use EnumDevices() for this, but it seems
4774  * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
4775  * relationship with reality. */
4776  for (i = 0; i < ARRAY_SIZE(z_depths); ++i)
4777  {
4778  memset(&surface_desc, 0, sizeof(surface_desc));
4779  surface_desc.dwSize = sizeof(surface_desc);
4780  surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
4781  surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
4782  U2(surface_desc).dwZBufferBitDepth = z_depths[i];
4783  surface_desc.dwWidth = rc.right;
4784  surface_desc.dwHeight = rc.bottom;
4785  if (FAILED(IDirectDraw2_CreateSurface(ddraw, &surface_desc, ds, NULL)))
4786  continue;
4787 
4788  hr = IDirectDrawSurface_AddAttachedSurface(surface, *ds);
4789  ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
4790  if (FAILED(hr))
4791  {
4792  IDirectDrawSurface_Release(*ds);
4793  continue;
4794  }
4795 
4796  if (SUCCEEDED(IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device)))
4797  break;
4798 
4799  IDirectDrawSurface_DeleteAttachedSurface(surface, 0, *ds);
4800  IDirectDrawSurface_Release(*ds);
4801  *ds = NULL;
4802  }
4803 
4804  IDirect3D2_Release(d3d);
4805  IDirectDrawSurface_Release(surface);
4806  return device;
4807 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
HRESULT hr
Definition: shlfolder.c:183
#define ds
Definition: i386-dis.c:434
LONG right
Definition: windef.h:293
#define IDirect3D2_Release(p)
Definition: d3d.h:280
#define IDirect3D2_CreateDevice(p, a, b, c)
Definition: d3d.h:287
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DDSD_CAPS
Definition: ddraw.h:208
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:267
#define DDSD_HEIGHT
Definition: ddraw.h:209
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static IHTMLWindow2 * window
Definition: events.c:77
#define U2(x)
Definition: wordpad.c:45
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:213
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
LONG bottom
Definition: windef.h:294
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_create_device_from_d3d2(), and test_create_device_from_d3d3().

◆ create_device2_without_ds()

static IDirect3DDevice2* create_device2_without_ds ( IDirectDraw2 *  ddraw,
HWND  window 
)
static

Definition at line 6037 of file d3drm.c.

6038 {
6039  IDirectDrawSurface *surface;
6040  IDirect3DDevice2 *device = NULL;
6041  DDSURFACEDESC surface_desc;
6042  IDirect3D2 *d3d;
6043  HRESULT hr;
6044  RECT rc;
6045 
6046  GetClientRect(window, &rc);
6047  hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
6048  ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
6049 
6050  memset(&surface_desc, 0, sizeof(surface_desc));
6051  surface_desc.dwSize = sizeof(surface_desc);
6052  surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
6053  surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
6054  surface_desc.dwWidth = rc.right;
6055  surface_desc.dwHeight = rc.bottom;
6056 
6057  hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
6058  ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
6059 
6060  hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
6061  if (FAILED(hr))
6062  {
6063  IDirectDrawSurface_Release(surface);
6064  return NULL;
6065  }
6066 
6067  IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device);
6068 
6069  IDirect3D2_Release(d3d);
6070  IDirectDrawSurface_Release(surface);
6071  return device;
6072 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
HRESULT hr
Definition: shlfolder.c:183
LONG right
Definition: windef.h:293
#define IDirect3D2_Release(p)
Definition: d3d.h:280
#define IDirect3D2_CreateDevice(p, a, b, c)
Definition: d3d.h:287
#define DDSD_CAPS
Definition: ddraw.h:208
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define DDSD_HEIGHT
Definition: ddraw.h:209
LONG HRESULT
Definition: typedefs.h:77
static IHTMLWindow2 * window
Definition: events.c:77
#define DDSD_WIDTH
Definition: ddraw.h:210
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ok(value,...)
Definition: atltest.h:57
LONG bottom
Definition: windef.h:294
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_viewport_clear2().

◆ create_window()

static HWND create_window ( void  )
static

Definition at line 85 of file d3drm.c.

86 {
87  RECT r = {0, 0, 640, 480};
88 
90 
91  return CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
92  CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
93 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4216
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620

Referenced by test_create_device_from_clipper1(), test_create_device_from_clipper2(), test_create_device_from_clipper3(), test_create_device_from_d3d1(), test_create_device_from_d3d2(), test_create_device_from_d3d3(), test_create_device_from_surface1(), test_create_device_from_surface2(), test_create_device_from_surface3(), test_create_texture_from_surface(), test_Device(), test_device_qi(), test_Viewport(), test_viewport_clear1(), and test_viewport_clear2().

◆ d3d_draw_quad1()

static void d3d_draw_quad1 ( IDirect3DDevice *  device,
IDirect3DViewport *  viewport 
)
static

Definition at line 6196 of file d3drm.c.

6197 {
6198  IDirect3DExecuteBuffer *execute_buffer;
6199  D3DEXECUTEBUFFERDESC exec_desc;
6200  HRESULT hr;
6201  void *ptr;
6202  UINT inst_length;
6203  D3DMATRIXHANDLE world_handle, view_handle, proj_handle;
6204  static D3DMATRIX mat =
6205  {
6206  1.0f, 0.0f, 0.0f, 0.0f,
6207  0.0f, 1.0f, 0.0f, 0.0f,
6208  0.0f, 0.0f, 1.0f, 0.0f,
6209  0.0f, 0.0f, 0.0f, 1.0f,
6210  };
6211  static const D3DLVERTEX quad_strip[] =
6212  {
6213  {{-1.0f}, {-1.0f}, {0.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6214  {{-1.0f}, { 1.0f}, {0.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6215  {{ 1.0f}, {-1.0f}, {1.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6216  {{ 1.0f}, { 1.0f}, {1.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6217  };
6218 
6219  hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
6220  ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
6221  hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat);
6222  ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
6223  hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
6224  ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
6225  hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat);
6226  ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
6227  hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
6228  ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
6229  hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat);
6230  ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
6231 
6232  memset(&exec_desc, 0, sizeof(exec_desc));
6233  exec_desc.dwSize = sizeof(exec_desc);
6234  exec_desc.dwFlags = D3DDEB_BUFSIZE | D3DDEB_CAPS;
6235  exec_desc.dwBufferSize = 1024;
6236  exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
6237 
6238  hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
6239  ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
6240 
6241  hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
6242  ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
6243 
6244  memcpy(exec_desc.lpData, quad_strip, sizeof(quad_strip));
6245  ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad_strip);
6246  emit_set_ts(&ptr, D3DTRANSFORMSTATE_WORLD, world_handle);
6247  emit_set_ts(&ptr, D3DTRANSFORMSTATE_VIEW, view_handle);
6254 
6256  emit_tquad(&ptr, 0);
6257 
6258  emit_end(&ptr);
6259  inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
6260  inst_length -= sizeof(quad_strip);
6261 
6262  hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
6263  ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
6264 
6266  set_execute_data(execute_buffer, 4, sizeof(quad_strip), inst_length);
6267  hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
6268  ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
6270  ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
6271 
6272  IDirect3DExecuteBuffer_Release(execute_buffer);
6273 }
#define IDirect3DExecuteBuffer_Unlock(p)
Definition: d3d.h:908
#define IDirect3DDevice_CreateExecuteBuffer(p, a, b, c)
Definition: d3d.h:971
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
static void emit_end(void **ptr)
Definition: d3drm.c:6185
#define D3DEXECUTE_CLIPPED
Definition: d3dtypes.h:1256
#define D3DDEBCAPS_SYSTEMMEMORY
Definition: d3dcaps.h:145
static const MAT2 mat
Definition: font.c:66
#define D3DDEB_CAPS
Definition: d3dcaps.h:143
#define IDirect3DExecuteBuffer_Lock(p, a)
Definition: d3d.h:907
static void emit_set_ts(void **ptr, D3DTRANSFORMSTATETYPE state, DWORD value)
Definition: d3drm.c:6113
Definition: devices.h:37
static void set_execute_data(IDirect3DExecuteBuffer *execute_buffer, UINT vertex_count, UINT offset, UINT len)
Definition: d3drm.c:6099
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define IDirect3DExecuteBuffer_Release(p)
Definition: d3d.h:904
DWORD D3DMATRIXHANDLE
Definition: d3dtypes.h:156
#define IDirect3DDevice_CreateMatrix(p, a)
Definition: d3d.h:980
LONG HRESULT
Definition: typedefs.h:77
static void emit_set_rs(void **ptr, D3DRENDERSTATETYPE state, DWORD value)
Definition: d3drm.c:6128
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define IDirect3DDevice_SetMatrix(p, a, b)
Definition: d3d.h:981
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice_Execute(p, a, b, c)
Definition: d3d.h:973
#define ok(value,...)
Definition: atltest.h:57
static void emit_tquad(void **ptr, WORD base_idx)
Definition: d3drm.c:6161
unsigned int UINT
Definition: ndis.h:50
static void emit_process_vertices(void **ptr, DWORD flags, WORD base_idx, DWORD vertex_count)
Definition: d3drm.c:6143
#define IDirect3DDevice_BeginScene(p)
Definition: d3d.h:984
#define D3DPROCESSVERTICES_TRANSFORM
Definition: d3dtypes.h:1055
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define D3DDEB_BUFSIZE
Definition: d3dcaps.h:142
#define IDirect3DDevice_EndScene(p)
Definition: d3d.h:985

Referenced by test_viewport_clear1().

◆ destroy_callback()

static void CDECL destroy_callback ( IDirect3DRMObject *  obj,
void arg 
)
static

Definition at line 1391 of file d3drm.c.

1392 {
1393  struct destroy_context *ctxt = arg;
1394  ok(ctxt->called == 1 || ctxt->called == 2, "got called counter %d\n", ctxt->called);
1395  ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1396  d3drm_corder[ctxt->called].callback = &destroy_callback;
1397  d3drm_corder[ctxt->called++].context = ctxt;
1398 }
static void CDECL destroy_callback(IDirect3DRMObject *obj, void *arg)
Definition: d3drm.c:1391
void * arg
Definition: msvc.h:12
struct callback_order d3drm_corder[3]
#define ok(value,...)
Definition: atltest.h:57
IDirect3DRMObject * obj
Definition: d3drm.c:1380

Referenced by test_destroy_callback().

◆ destroy_callback1()

static void CDECL destroy_callback1 ( IDirect3DRMObject *  obj,
void arg 
)
static

Definition at line 1400 of file d3drm.c.

1401 {
1402  struct destroy_context *ctxt = (struct destroy_context*)arg;
1403  ok(ctxt->called == 0, "got called counter %d\n", ctxt->called);
1404  ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1405  d3drm_corder[ctxt->called].callback = &destroy_callback1;
1406  d3drm_corder[ctxt->called++].context = ctxt;
1407 }
static void CDECL destroy_callback1(IDirect3DRMObject *obj, void *arg)
Definition: d3drm.c:1400
struct callback_order d3drm_corder[3]
#define ok(value,...)
Definition: atltest.h:57
IDirect3DRMObject * obj
Definition: d3drm.c:1380

Referenced by test_destroy_callback().

◆ draw_quad2()

static void draw_quad2 ( IDirect3DDevice2 *  device,
IDirect3DViewport *  viewport 
)
static

Definition at line 6429 of file d3drm.c.

6430 {
6431  static D3DLVERTEX tquad[] =
6432  {
6433  {{-1.0f}, {-1.0f}, {0.0f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6434  {{-1.0f}, { 1.0f}, {0.0f}, 0, {0xffbada55}, {0}, {0.0f}, {1.0f}},
6435  {{ 1.0f}, {-1.0f}, {1.0f}, 0, {0xffbada55}, {0}, {1.0f}, {0.0f}},
6436  {{ 1.0f}, { 1.0f}, {1.0f}, 0, {0xffbada55}, {0}, {1.0f}, {1.0f}},
6437  };
6438  static D3DMATRIX mat =
6439  {
6440  1.0f, 0.0f, 0.0f, 0.0f,
6441  0.0f, 1.0f, 0.0f, 0.0f,
6442  0.0f, 0.0f, 1.0f, 0.0f,
6443  0.0f, 0.0f, 0.0f, 1.0f,
6444  };
6445  IDirect3DViewport2 *viewport2;
6446  HRESULT hr;
6447 
6449  ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
6451  ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
6453  ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
6454 
6455  hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport2, (void **)&viewport2);
6456  ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport2 interface (hr = %#x).\n", hr);
6458  ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
6459  IDirect3DViewport2_Release(viewport2);
6460 
6462  ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#x.\n", hr);
6464  ok(SUCCEEDED(hr), "Failed to set the z function, hr %#x.\n", hr);
6465 
6467  ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
6469  ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
6471  ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
6472 }
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DViewport_QueryInterface(p, a, b)
Definition: d3d.h:674
#define IDirect3DDevice2_SetTransform(p, a, b)
Definition: d3d.h:1089
static const MAT2 mat
Definition: font.c:66
#define IDirect3DDevice2_SetRenderState(p, a, b)
Definition: d3d.h:1086
#define IDirect3DDevice2_SetCurrentViewport(p, a)
Definition: d3d.h:1076
Definition: devices.h:37
#define IDirect3DDevice2_DrawPrimitive(p, a, b, c, d, e)
Definition: d3d.h:1092
LONG HRESULT
Definition: typedefs.h:77
#define IDirect3DDevice2_EndScene(p)
Definition: d3d.h:1074
#define ok(value,...)
Definition: atltest.h:57
#define IDirect3DViewport2_Release(p)
Definition: d3d.h:747
#define IDirect3DDevice2_BeginScene(p)
Definition: d3d.h:1073
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_viewport_clear2().

◆ emit_end()

static void emit_end ( void **  ptr)
static

Definition at line 6185 of file d3drm.c.

6186 {
6187  D3DINSTRUCTION *inst = *ptr;
6188 
6189  inst->bOpcode = D3DOP_EXIT;
6190  inst->bSize = 0;
6191  inst->wCount = 0;
6192 
6193  *ptr = inst + 1;
6194 }
static PVOID ptr
Definition: dispmode.c:27

Referenced by d3d_draw_quad1().

◆ emit_process_vertices()

static void emit_process_vertices ( void **  ptr,
DWORD  flags,
WORD  base_idx,
DWORD  vertex_count 
)
static

Definition at line 6143 of file d3drm.c.

6144 {
6145  D3DINSTRUCTION *inst = *ptr;
6146  D3DPROCESSVERTICES *pv = (D3DPROCESSVERTICES *)(inst + 1);
6147 
6149  inst->bSize = sizeof(*pv);
6150  inst->wCount = 1;
6151 
6152  pv->dwFlags = flags;
6153  pv->wStart = base_idx;
6154  pv->wDest = 0;
6155  pv->dwCount = vertex_count;
6156  pv->dwReserved = 0;
6157 
6158  *ptr = pv + 1;
6159 }
int vertex_count
Definition: d3drm.c:2807
static PVOID ptr
Definition: dispmode.c:27
GLbitfield flags
Definition: glext.h:7161

Referenced by d3d_draw_quad1().

◆ emit_set_rs()

static void emit_set_rs ( void **  ptr,
D3DRENDERSTATETYPE  state,
DWORD  value 
)
static

Definition at line 6128 of file d3drm.c.

6129 {
6130  D3DINSTRUCTION *inst = *ptr;
6131  D3DSTATE *rs = (D3DSTATE *)(inst + 1);
6132 
6133  inst->bOpcode = D3DOP_STATERENDER;
6134  inst->bSize = sizeof(*rs);
6135  inst->wCount = 1;
6136 
6137  U1(*rs).drstRenderStateType = state;
6138  U2(*rs).dwArg[0] = value;
6139 
6140  *ptr = rs + 1;
6141 }
#define U1(x)
Definition: test.h:172
static PVOID ptr
Definition: dispmode.c:27
static int state
Definition: maze.c:121
#define U2(x)
Definition: wordpad.c:45

Referenced by d3d_draw_quad1().

◆ emit_set_ts()

static void emit_set_ts ( void **  ptr,
D3DTRANSFORMSTATETYPE  state,
DWORD  value 
)
static

Definition at line 6113 of file d3drm.c.

6114 {
6115  D3DINSTRUCTION *inst = *ptr;
6116  D3DSTATE *ts = (D3DSTATE *)(inst + 1);
6117 
6118  inst->bOpcode = D3DOP_STATETRANSFORM;
6119  inst->bSize = sizeof(*ts);
6120  inst->wCount = 1;
6121 
6122  U1(*ts).dtstTransformStateType = state;
6123  U2(*ts).dwArg[0] = value;
6124 
6125  *ptr = ts + 1;
6126 }
#define U1(x)
Definition: test.h:172
static PVOID ptr
Definition: dispmode.c:27
static const char * ts(int t)
static int state
Definition: maze.c:121
#define U2(x)
Definition: wordpad.c:45

Referenced by d3d_draw_quad1().

◆ emit_tquad()

static void emit_tquad ( void **  ptr,
WORD  base_idx 
)
static

Definition at line 6161 of file d3drm.c.

6162 {
6163  D3DINSTRUCTION *inst = *ptr;
6164  D3DTRIANGLE *tri = (D3DTRIANGLE *)(inst + 1);
6165 
6166  inst->bOpcode = D3DOP_TRIANGLE;
6167  inst->bSize = sizeof(*tri);
6168  inst->wCount = 2;
6169 
6170  U1(*tri).v1 = base_idx;
6171  U2(*tri).v2 = base_idx + 1;
6172  U3(*tri).v3 = base_idx + 2;
6173  tri->wFlags = D3DTRIFLAG_START;
6174  ++tri;
6175 
6176  U1(*tri).v1 = base_idx + 2;
6177  U2(*tri).v2 = base_idx + 1;
6178  U3(*tri).v3 = base_idx + 3;
6179  tri->wFlags = D3DTRIFLAG_ODD;
6180  ++tri;
6181 
6182  *ptr = tri;
6183 }
#define U1(x)
Definition: test.h:172
#define U3(x)
Definition: wordpad.c:46
static PVOID ptr
Definition: dispmode.c:27
#define D3DTRIFLAG_START
Definition: d3dtypes.h:1170
#define U2(x)
Definition: wordpad.c:45
#define D3DTRIFLAG_ODD
Definition: d3dtypes.h:1172

Referenced by d3d_draw_quad1().

◆ get_refcount()

◆ get_surface_color()

static D3DCOLOR get_surface_color ( IDirectDrawSurface *  surface,
UINT  x,
UINT  y 
)
static

Definition at line 6014 of file d3drm.c.

6015 {
6016  RECT rect = { x, y, x + 1, y + 1 };
6017  DDSURFACEDESC surface_desc;
6018  D3DCOLOR color;
6019  HRESULT hr;
6020 
6021  memset(&surface_desc, 0, sizeof(surface_desc));
6022  surface_desc.dwSize = sizeof(surface_desc);
6023 
6024  hr = IDirectDrawSurface_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
6025  ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
6026  if (FAILED(hr))
6027  return 0xdeadbeef;
6028 
6029  color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
6030 
6031  hr = IDirectDrawSurface_Unlock(surface, NULL);
6032  ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
6033 
6034  return color;
6035 }
HRESULT hr
Definition: shlfolder.c:183
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define DDLOCK_READONLY
Definition: ddraw.h:624
& rect
Definition: startmenu.cpp:1413
GLuint color
Definition: glext.h:6243
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DDLOCK_WAIT
Definition: ddraw.h:622
#define ok(value,...)
Definition: atltest.h:57
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define memset(x, y, z)
Definition: compat.h:39
DWORD color
Definition: d3drm.c:2811
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_viewport_clear1(), and test_viewport_clear2().

◆ object_load_callback()

static void __cdecl object_load_callback ( IDirect3DRMObject *  object,
REFIID  objectguid,
void arg 
)
static

Definition at line 2742 of file d3drm.c.

2743 {
2744  ok(object != NULL, "Arg 1 should not be null\n");
2745  ok(IsEqualGUID(objectguid, refiids[nb_objects]), "Arg 2 is incorrect\n");
2746  ok(arg == (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg);
2747  nb_objects++;
2748 }
static int nb_objects
Definition: d3drm.c:2733
smooth NULL
Definition: ftsmooth.c:416
static const GUID * refiids[]
Definition: d3drm.c:2734
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

Referenced by test_d3drm_load().

◆ object_load_callback_frame()

static void __cdecl object_load_callback_frame ( IDirect3DRMObject *  object,
REFIID  object_guid,
void arg 
)
static

Definition at line 2772 of file d3drm.c.

2773 {
2774  HRESULT hr;
2775  IDirect3DRMFrame *frame;
2776  IDirect3DRMVisualArray *array;
2777  IDirect3DRMVisual *visual;
2778  ULONG size;
2779  char name[128];
2780 
2781  hr = IDirect3DRMObject_QueryInterface(object, &IID_IDirect3DRMFrame, (void**)&frame);
2782  ok(hr == D3DRM_OK, "IDirect3DRMObject_QueryInterface returned %x\n", hr);
2783 
2785  ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetVisuals returned %x\n", hr);
2786 
2788  ok(size == 1, "Wrong size %u returned, expected 1\n", size);
2789 
2791  ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetElement returned %x\n", hr);
2792 
2793  hr = IDirect3DRMVisual_QueryInterface(visual, &IID_IDirect3DRMMeshBuilder, (void**)&mesh_builder);
2794  ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetSize returned %x\n", hr);
2795 
2796  size = sizeof(name);
2798  ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr);
2799  ok(!strcmp(name, "mesh1"), "Wrong name %s, expected mesh1\n", name);
2800 
2801  IDirect3DRMVisual_Release(visual);
2803  IDirect3DRMFrame_Release(frame);
2804 }
#define IDirect3DRMVisualArray_GetElement(p, a, b)
Definition: d3drmobj.h:4350
#define IDirect3DRMFrame_GetVisuals(p, a)
Definition: d3drmobj.h:1200
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DRMObject_QueryInterface(p, a, b)
Definition: d3drmobj.h:218
#define IDirect3DRMVisual_QueryInterface(p, a, b)
Definition: d3drmobj.h:328
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
#define D3DRM_OK
Definition: d3drm.h:486
#define IDirect3DRMVisual_Release(p)
Definition: d3drmobj.h:330
IDirect3DRMMeshBuilder * mesh_builder
Definition: d3drm.c:2770
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
#define IDirect3DRMVisualArray_GetSize(p)
Definition: d3drmobj.h:4348
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define IDirect3DRMFrame_Release(p)
Definition: d3drmobj.h:1168
#define IDirect3DRMVisualArray_Release(p)
Definition: d3drmobj.h:4346
#define IDirect3DRMMeshBuilder_GetName(p, a, b)
Definition: d3drmobj.h:2560
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by test_frame_mesh_materials().

◆ set_execute_data()

static void set_execute_data ( IDirect3DExecuteBuffer *  execute_buffer,
UINT  vertex_count,
UINT  offset,
UINT  len 
)
static

Definition at line 6099 of file d3drm.c.

6100 {
6101  D3DEXECUTEDATA exec_data;
6102  HRESULT hr;
6103 
6104  memset(&exec_data, 0, sizeof(exec_data));
6105  exec_data.dwSize = sizeof(exec_data);
6106  exec_data.dwVertexCount = vertex_count;
6107  exec_data.dwInstructionOffset = offset;
6108  exec_data.dwInstructionLength = len;
6109  hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
6110  ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
6111 }
HRESULT hr
Definition: shlfolder.c:183
GLintptr offset
Definition: glext.h:5920
int vertex_count
Definition: d3drm.c:2807
DWORD dwInstructionLength
Definition: d3dtypes.h:1264
DWORD dwInstructionOffset
Definition: d3dtypes.h:1263
LONG HRESULT
Definition: typedefs.h:77
#define IDirect3DExecuteBuffer_SetExecuteData(p, a)
Definition: d3d.h:909
DWORD dwVertexCount
Definition: d3dtypes.h:1262
GLenum GLsizei len
Definition: glext.h:6722
#define ok(value,...)
Definition: atltest.h:57
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by d3d_draw_quad1().

◆ START_TEST()

START_TEST ( d3drm  )

Definition at line 7407 of file d3drm.c.

7408 {
7409  test_MeshBuilder();
7411  test_Mesh();
7412  test_Face();
7413  test_Frame();
7414  test_Device();
7415  test_object();
7416  test_Viewport();
7417  test_Light();
7418  test_Material2();
7419  test_Texture();
7421  test_d3drm_load();
7423  test_d3drm_qi();
7424  test_frame_qi();
7425  test_device_qi();
7436  test_texture_qi();
7437  test_viewport_qi();
7441  test_animation();
7443  test_wrap();
7444  test_wrap_qi();
7445 }
static void test_create_device_from_clipper2(void)
Definition: d3drm.c:3469
static void test_Light(void)
Definition: d3drm.c:2199
static void test_animation_qi(void)
Definition: d3drm.c:7196
static void test_d3drm_load(void)
Definition: d3drm.c:2750
static void test_texture_qi(void)
Definition: d3drm.c:5743
static void test_MeshBuilder3(void)
Definition: d3drm.c:642
static void test_create_texture_from_surface(void)
Definition: d3drm.c:6687
static void test_Device(void)
Definition: d3drm.c:2663
static void test_create_device_from_d3d1(void)
Definition: d3drm.c:4474
static void test_frame_transform(void)
Definition: d3drm.c:2712
static void test_Material2(void)
Definition: d3drm.c:2247
static void test_device_qi(void)
Definition: d3drm.c:3153
static void test_viewport_clear2(void)
Definition: d3drm.c:6474
static void test_create_device_from_clipper1(void)
Definition: d3drm.c:3299
static void test_viewport_qi(void)
Definition: d3drm.c:5868
static void test_create_device_from_surface3(void)
Definition: d3drm.c:4178
static void test_Face(void)
Definition: d3drm.c:770
static void test_frame_mesh_materials(void)
Definition: d3drm.c:2821
static void test_create_device_from_d3d3(void)
Definition: d3drm.c:5092
static void test_d3drm_qi(void)
Definition: d3drm.c:2952
static void test_object(void)
Definition: d3drm.c:1511
static void test_wrap_qi(void)
Definition: d3drm.c:7319
static void test_load_texture(void)
Definition: d3drm.c:5563
static void test_animation(void)
Definition: d3drm.c:6853
static void test_create_device_from_clipper3(void)
Definition: d3drm.c:3647
static void test_frame_qi(void)
Definition: d3drm.c:3036
static void test_viewport_clear1(void)
Definition: d3drm.c:6275
static void test_MeshBuilder(void)
Definition: d3drm.c:358
static void test_Frame(void)
Definition: d3drm.c:985
static void test_Texture(void)
Definition: d3drm.c:2315
static void test_wrap(void)
Definition: d3drm.c:7301
static void test_Viewport(void)
Definition: d3drm.c:1649
static void test_Mesh(void)
Definition: d3drm.c:741
static void test_create_device_from_surface2(void)
Definition: d3drm.c:3996
static void test_create_device_from_d3d2(void)
Definition: d3drm.c:4809
static void test_create_device_from_surface1(void)
Definition: d3drm.c:3825

◆ surface_callback()

static HRESULT CALLBACK surface_callback ( IDirectDrawSurface *  surface,
DDSURFACEDESC desc,
void context 
)
static

Definition at line 3285 of file d3drm.c.

3286 {
3287  IDirectDrawSurface **primary = context;
3288 
3289  if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
3290  {
3291  *primary = surface;
3292  return DDENUMRET_CANCEL;
3293  }
3294  IDirectDrawSurface_Release(surface);
3295 
3296  return DDENUMRET_OK;
3297 }
Definition: http.c:6587
#define DDENUMRET_CANCEL
Definition: ddraw.h:188
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define DDENUMRET_OK
Definition: ddraw.h:189
#define DDSCAPS_PRIMARYSURFACE
Definition: ddraw.h:258

Referenced by test_create_device_from_clipper1(), test_create_device_from_clipper2(), test_create_device_from_clipper3(), test_create_device_from_d3d1(), test_create_device_from_d3d2(), test_create_device_from_d3d3(), test_create_device_from_surface1(), test_create_device_from_surface2(), and test_create_device_from_surface3().

◆ test_animation()

static void test_animation ( void  )
static

Definition at line 6853 of file d3drm.c.

6854 {
6855  IDirect3DRMAnimation2 *animation2;
6856  IDirect3DRMAnimation *animation;
6858  IDirect3DRMObject *obj, *obj2;
6859  D3DRMANIMATIONKEY keys[10];
6860  IDirect3DRMFrame3 *frame3;
6861  IDirect3DRMFrame *frame;
6863  IDirect3DRM *d3drm1;
6865  DWORD count, i;
6866  HRESULT hr;
6867  D3DVECTOR v;
6868 
6869  hr = Direct3DRMCreate(&d3drm1);
6870  ok(SUCCEEDED(hr), "Failed to create IDirect3DRM instance, hr 0x%08x.\n", hr);
6871 
6872  hr = IDirect3DRM_CreateAnimation(d3drm1, NULL);
6873  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr 0x%08x.\n", hr);
6874 
6875  CHECK_REFCOUNT(d3drm1, 1);
6876  hr = IDirect3DRM_CreateAnimation(d3drm1, &animation);
6877  ok(SUCCEEDED(hr), "Failed to create animation hr 0x%08x.\n", hr);
6878  CHECK_REFCOUNT(d3drm1, 2);
6879 
6880  test_class_name((IDirect3DRMObject *)animation, "Animation");
6881 
6882  hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IDirect3DRMAnimation2, (void **)&animation2);
6883  ok(SUCCEEDED(hr), "Failed to get IDirect3DRMAnimation2, hr 0x%08x.\n", hr);
6884  ok(animation != (void *)animation2, "Expected different interface pointer.\n");
6885 
6886  hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IDirect3DRMObject, (void **)&obj);
6887  ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr 0x%08x.\n", hr);
6888 
6889  hr = IDirect3DRMAnimation2_QueryInterface(animation2, &IID_IDirect3DRMObject, (void **)&obj2);
6890  ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr 0x%08x.\n", hr);
6891 
6892  ok(obj == obj2 && obj == (IDirect3DRMObject *)animation, "Unexpected object pointer.\n");
6893 
6896 
6897  /* Set animated frame, get it back. */
6898  hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame);
6899  ok(SUCCEEDED(hr), "Failed to create a frame, hr %#x.\n", hr);
6900 
6901  hr = IDirect3DRMAnimation_SetFrame(animation, NULL);
6902  ok(SUCCEEDED(hr), "Failed to reset frame, hr %#x.\n", hr);
6903 
6904  CHECK_REFCOUNT(frame, 1);
6905  hr = IDirect3DRMAnimation_SetFrame(animation, frame);
6906  ok(SUCCEEDED(hr), "Failed to set a frame, hr %#x.\n", hr);
6907  CHECK_REFCOUNT(frame, 1);
6908 
6909  hr = IDirect3DRMAnimation2_GetFrame(animation2, NULL);
6910  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
6911 
6912  hr = IDirect3DRMAnimation2_GetFrame(animation2, &frame3);
6913  ok(SUCCEEDED(hr), "Failed to get the frame, %#x.\n", hr);
6914  ok(frame3 != (void *)frame, "Unexpected interface pointer.\n");
6915  CHECK_REFCOUNT(frame, 2);
6916 
6917  IDirect3DRMFrame3_Release(frame3);
6918 
6919  hr = IDirect3DRMAnimation_SetFrame(animation, NULL);
6920  ok(SUCCEEDED(hr), "Failed to reset frame, hr %#x.\n", hr);
6921 
6922  hr = IDirect3DRMFrame_QueryInterface(frame, &IID_IDirect3DRMFrame3, (void **)&frame3);
6923  ok(SUCCEEDED(hr), "Failed to get IDirect3DRMFrame3, hr %#x.\n", hr);
6924 
6925  CHECK_REFCOUNT(frame3, 2);
6926  hr = IDirect3DRMAnimation2_SetFrame(animation2, frame3);
6927  ok(SUCCEEDED(hr), "Failed to set a frame, hr %#x.\n", hr);
6928  CHECK_REFCOUNT(frame3, 2);
6929 
6930  IDirect3DRMFrame3_Release(frame3);
6931  IDirect3DRMFrame_Release(frame);
6932 
6933  /* Animation options. */
6936  "Unexpected default options %#x.\n", options);
6937 
6938  /* Undefined mask value */
6939  hr = IDirect3DRMAnimation_SetOptions(animation, 0xf0000000);
6940  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
6941 
6944  "Unexpected default options %#x.\n", options);
6945 
6946  /* Ambiguous mask */
6948  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
6949 
6951  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
6952 
6954  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
6955 
6958  "Unexpected default options %#x.\n", options);
6959 
6960  /* Mask contains undefined bits together with valid one. */
6961  hr = IDirect3DRMAnimation_SetOptions(animation, 0xf0000000 | D3DRMANIMATION_OPEN);
6962  ok(SUCCEEDED(hr), "Failed to set animation options, hr %#x.\n", hr);
6963 
6965  ok(options == (0xf0000000 | D3DRMANIMATION_OPEN), "Unexpected animation options %#x.\n", options);
6966 
6968  ok(SUCCEEDED(hr), "Failed to set animation options, hr %#x.\n", hr);
6969 
6971  ok(options == D3DRMANIMATION_SCALEANDROTATION, "Unexpected options %#x.\n", options);
6972 
6974  ok(SUCCEEDED(hr), "Failed to set animation options, hr %#x.\n", hr);
6975 
6977  ok(options == D3DRMANIMATION_OPEN, "Unexpected options %#x.\n", options);
6978 
6979  hr = IDirect3DRMAnimation_SetOptions(animation, 0);
6980  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
6981 
6983  ok(options == D3DRMANIMATION_OPEN, "Unexpected options %#x.\n", options);
6984 
6985  /* Key management. */
6986  hr = IDirect3DRMAnimation_AddPositionKey(animation, 0.0f, 1.0f, 0.0f, 0.0f);
6987  ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
6988 
6989  hr = IDirect3DRMAnimation_AddScaleKey(animation, 0.0f, 1.0f, 2.0f, 1.0f);
6990  ok(SUCCEEDED(hr), "Failed to add scale key, hr %#x.\n", hr);
6991 
6992  hr = IDirect3DRMAnimation_AddPositionKey(animation, 0.0f, 2.0f, 0.0f, 0.0f);
6993  ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
6994 
6995  hr = IDirect3DRMAnimation_AddPositionKey(animation, 99.0f, 3.0f, 1.0f, 0.0f);
6996  ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
6997 
6998  hr = IDirect3DRMAnimation_AddPositionKey(animation, 80.0f, 4.0f, 1.0f, 0.0f);
6999  ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
7000 
7001  v.x = 1.0f;
7002  v.y = 0.0f;
7003  v.z = 0.0f;
7004  D3DRMQuaternionFromRotation(&q, &v, 1.0f);
7005 
7006  /* NULL quaternion pointer leads to a crash on Windows. */
7007  hr = IDirect3DRMAnimation_AddRotateKey(animation, 0.0f, &q);
7008  ok(SUCCEEDED(hr), "Failed to add rotation key, hr %#.x\n", hr);
7009 
7010  count = 0;
7011  memset(keys, 0, sizeof(keys));
7012  hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 99.0f, &count, keys);
7013  ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#x.\n", hr);
7014  ok(count == 6, "Unexpected key count %u.\n", count);
7015 
7016  ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[0].dwKeyType);
7017  ok(keys[1].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[1].dwKeyType);
7018  ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[2].dwKeyType);
7019  ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[3].dwKeyType);
7020  ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[4].dwKeyType);
7021  ok(keys[5].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[5].dwKeyType);
7022 
7023  /* Relative order, keys are returned sorted by time. */
7024  ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7025  ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7026  ok(keys[3].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7027  ok(keys[4].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7028 
7029  /* For keys with same time, order they were added in is kept. */
7030  ok(keys[1].dvPositionKey.x == 1.0f, "Unexpected key position x %.8e.\n", keys[1].dvPositionKey.x);
7031  ok(keys[2].dvPositionKey.x == 2.0f, "Unexpected key position x %.8e.\n", keys[2].dvPositionKey.x);
7032  ok(keys[3].dvPositionKey.x == 4.0f, "Unexpected key position x %.8e.\n", keys[3].dvPositionKey.x);
7033  ok(keys[4].dvPositionKey.x == 3.0f, "Unexpected key position x %.8e.\n", keys[4].dvPositionKey.x);
7034 
7035  for (i = 0; i < count; i++)
7036  {
7037  ok(keys[i].dwSize == sizeof(*keys), "%u: unexpected dwSize value %u.\n", i, keys[i].dwSize);
7038 
7039  todo_wine
7040  {
7041  switch (keys[i].dwKeyType)
7042  {
7044  ok((keys[i].dwID & 0xf0000000) == 0x40000000, "%u: unexpected id mask %#x.\n", i, keys[i].dwID);
7045  break;
7047  ok((keys[i].dwID & 0xf0000000) == 0x80000000, "%u: unexpected id mask %#x.\n", i, keys[i].dwID);
7048  break;
7050  ok((keys[i].dwID & 0xf0000000) == 0xc0000000, "%u: unexpected id mask %#x.\n", i, keys[i].dwID);
7051  break;
7052  default:
7053  ok(0, "%u: unknown key type %d.\n", i, keys[i].dwKeyType);
7054  }
7055  }
7056  }
7057 
7058  /* No keys in this range. */
7059  count = 10;
7060  hr = IDirect3DRMAnimation2_GetKeys(animation2, 100.0f, 200.0f, &count, NULL);
7061  ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#x.\n", hr);
7062  ok(count == 0, "Unexpected key count %u.\n", count);
7063 
7064  count = 10;
7065  hr = IDirect3DRMAnimation2_GetKeys(animation2, 100.0f, 200.0f, &count, keys);
7066  ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#x.\n", hr);
7067  ok(count == 0, "Unexpected key count %u.\n", count);
7068 
7069  count = 10;
7070  hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 0.0f, &count, NULL);
7071  ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#x.\n", hr);
7072  ok(count == 4, "Unexpected key count %u.\n", count);
7073 
7074  hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, NULL, NULL);
7075  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7076 
7077  /* Time is 0-based. */
7078  hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, -50.0f, NULL, NULL);
7079  ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7080 
7081  count = 10;
7082  hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, -50.0f, &count, NULL);
7083  ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#x.\n", hr);
7084  ok(count == 0, "Unexpected key count %u.\n", count);
7085 
7086  count = 10;
7087  hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, 100.0f, &count, NULL);
7088  ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#x.\n", hr);
7089  ok(count == 6, "Unexpected key count %u.\n", count);
7090 
7091  /* AddKey() tests. */
7092  hr = IDirect3DRMAnimation2_AddKey(animation2, NULL);
7093  ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7094 
7095  memset(&key, 0, sizeof(key));
7096  key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7097  hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7098  ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7099 
7100  memset(&key, 0, sizeof(key));
7101  key.dwSize = sizeof(key) - 1;
7102  key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7103  hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7104  ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7105 
7106  memset(&key, 0, sizeof(key));
7107  key.dwSize = sizeof(key) + 1;
7108  key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7109  hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7110  ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7111 
7112  memset(&key, 0, sizeof(key));
7113  key.dwSize = sizeof(key);
7114  key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7115  key.dvPositionKey.x = 8.0f;
7116  hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7117  ok(SUCCEEDED(hr), "Failed to add key, hr %#x.\n", hr);
7118 
7119  /* Delete tests. */
7120  hr = IDirect3DRMAnimation_AddRotateKey(animation, 0.0f, &q);
7121  ok(SUCCEEDED(hr), "Failed to add rotation key, hr %#.x\n", hr);
7122 
7123  hr = IDirect3DRMAnimation_AddScaleKey(animation, 0.0f, 1.0f, 2.0f, 1.0f);
7124  ok(SUCCEEDED(hr), "Failed to add scale key, hr %#x.\n", hr);
7125 
7126  count = 0;
7127  memset(keys, 0, sizeof(keys));
7128  hr = IDirect3DRMAnimation2_GetKeys(animation2, -1000.0f, 1000.0f, &count, keys);
7129  ok(SUCCEEDED(hr), "Failed to get key count, hr %#x.\n", hr);
7130  ok(count == 9, "Unexpected key count %u.\n", count);
7131 
7132  ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[0].dwKeyType);
7133  ok(keys[1].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[1].dwKeyType);
7134  ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[2].dwKeyType);
7135  ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[3].dwKeyType);
7136  ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[4].dwKeyType);
7137  ok(keys[5].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[5].dwKeyType);
7138  ok(keys[6].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[6].dwKeyType);
7139  ok(keys[7].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[7].dwKeyType);
7140  ok(keys[8].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[8].dwKeyType);
7141 
7142  ok(keys[0].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[0].dvTime);
7143  ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7144  ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7145  ok(keys[3].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7146  ok(keys[4].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7147  ok(keys[5].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[5].dvTime);
7148  ok(keys[6].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[6].dvTime);
7149  ok(keys[7].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[7].dvTime);
7150  ok(keys[8].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[8].dvTime);
7151 
7152  hr = IDirect3DRMAnimation_DeleteKey(animation, -100.0f);
7153  ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7154 
7155  hr = IDirect3DRMAnimation_DeleteKey(animation, 100.0f);
7156  ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7157 
7158  /* Only first Position keys are not removed. */
7159  hr = IDirect3DRMAnimation_DeleteKey(animation, 0.0f);
7160  ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7161 
7162  count = 0;
7163  memset(keys, 0, sizeof(keys));
7164  hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, &count, keys);
7165  ok(SUCCEEDED(hr), "Failed to get key count, hr %#x.\n", hr);
7166  ok(count == 6, "Unexpected key count %u.\n", count);
7167 
7168  ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[0].dwKeyType);
7169  ok(keys[1].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[1].dwKeyType);
7170  ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[2].dwKeyType);
7171  ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[3].dwKeyType);
7172  ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[4].dwKeyType);
7173  ok(keys[5].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[5].dwKeyType);
7174 
7175  ok(keys[0].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[0].dvTime);
7176  ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7177  ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7178  ok(keys[3].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7179  ok(keys[4].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7180  ok(keys[5].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[5].dvTime);
7181 
7182  hr = IDirect3DRMAnimation_DeleteKey(animation, 0.0f);
7183  ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7184 
7185  count = 0;
7186  hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, &count, NULL);
7187  ok(SUCCEEDED(hr), "Failed to get key count, hr %#x.\n", hr);
7188  ok(count == 3, "Unexpected key count %u.\n", count);
7189 
7190  IDirect3DRMAnimation2_Release(animation2);
7191  IDirect3DRMAnimation_Release(animation);
7192 
7193  IDirect3DRM_Release(d3drm1);
7194 }
#define D3DRMANIMATION_POSITION
Definition: d3drmdef.h:328
#define CHECK_REFCOUNT(obj, rc)
Definition: d3drm.c:32
#define IDirect3DRMAnimation_AddRotateKey(p, a, b)
Definition: d3drmobj.h:3823
#define IDirect3DRMAnimation2_Release(p)
Definition: d3drmobj.h:3895
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DRMAnimation2_SetFrame(p, a)
Definition: d3drmobj.h:3911
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD D3DRMANIMATIONOPTIONS
Definition: d3drmdef.h:322
#define IDirect3DRM_CreateFrame(p, a, b)
Definition: d3drm.h:114
#define IDirect3DRMAnimation_AddScaleKey(p, a, b, c, d)
Definition: d3drmobj.h:3825
#define D3DRMANIMATION_LINEARPOSITION
Definition: d3drmdef.h:325
#define IDirect3DRMAnimation2_GetKeys(p, a, b, c, d)
Definition: d3drmobj.h:3918
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
#define D3DRMANIMATION_CLOSED
Definition: d3drmdef.h:324
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define test_class_name(a, b)
Definition: d3drm.c:95
#define IDirect3DRMAnimation_QueryInterface(p, a, b)
Definition: d3drmobj.h:3809
#define D3DRMANIMATION_SCALEKEY
Definition: d3drmdef.h:415
#define IDirect3DRMAnimation_SetOptions(p, a)
Definition: d3drmobj.h:3822
#define E_INVALIDARG
Definition: ddrawi.h:101
#define D3DRMANIMATION_OPEN
Definition: d3drmdef.h:323
smooth NULL
Definition: ftsmooth.c:416
#define IDirect3DRMFrame3_Release(p)
Definition: d3drmobj.h:1708
int options
Definition: main.c:106
#define D3DRMANIMATION_ROTATEKEY
Definition: d3drmdef.h:414
GLfloat f
Definition: glext.h:7540
HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
Definition: d3drm.c:2333
#define D3DRMANIMATION_SPLINEPOSITION
Definition: d3drmdef.h:326
LONG HRESULT
Definition: typedefs.h:77
#define IDirect3DRMAnimation_AddPositionKey(p, a, b, c, d)
Definition: d3drmobj.h:3824
#define IDirect3DRM_CreateAnimation(p, a)
Definition: d3drm.h:118
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define IDirect3DRMAnimation2_GetFrame(p, a)
Definition: d3drmobj.h:3914
#define D3DRMANIMATION_SCALEANDROTATION
Definition: d3drmdef.h:327
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496
#define todo_wine
Definition: test.h:154
#define D3DRMANIMATION_POSITIONKEY
Definition: d3drmdef.h:416
HKEY key
Definition: reg.c:42
#define D3DRMERR_NOSUCHKEY
Definition: d3drm.h:514
#define IDirect3DRMAnimation_Release(p)
Definition: d3drmobj.h:3811
#define IDirect3DRMFrame_QueryInterface(p, a, b)
Definition: d3drmobj.h:1166
#define IDirect3DRMAnimation2_AddKey(p, a)
Definition: d3drmobj.h:3916
const GLdouble * v
Definition: gl.h:2040
#define ok(value,...)
Definition: atltest.h:57
#define IDirect3DRMAnimation_DeleteKey(p, a)
Definition: d3drmobj.h:3826
#define IDirect3DRMAnimation_GetOptions(p)
Definition: d3drmobj.h:3829
D3DRMQUATERNION *WINAPI D3DRMQuaternionFromRotation(D3DRMQUATERNION *q, D3DVECTOR *v, D3DVALUE theta)
Definition: math.c:107
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
#define IDirect3DRMObject_Release(p)
Definition: d3drmobj.h:220
#define IDirect3DRMFrame_Release(p)
Definition: d3drmobj.h:1168
#define memset(x, y, z)
Definition: compat.h:39
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define IDirect3DRMAnimation_SetFrame(p, a)
Definition: d3drmobj.h:3827
#define IDirect3DRMAnimation2_QueryInterface(p, a, b)
Definition: d3drmobj.h:3893
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: path.c:42

Referenced by START_TEST().

◆ test_animation_qi()

static void test_animation_qi ( void  )
static

Definition at line 7196 of file d3drm.c.

7197 {
7198  static const struct qi_test tests[] =
7199  {
7200  { &IID_IDirect3DRMAnimation2, &IID_IUnknown, &IID_IDirect3DRMAnimation2, S_OK },
7201  { &IID_IDirect3DRMAnimation, &IID_IUnknown, &IID_IDirect3DRMAnimation, S_OK },
7202  { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7203  { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7204  { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMAnimation, S_OK },
7205  { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7206  { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7207  { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7208  { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7209  { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7210  { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7211  { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7212  { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7213  { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7214  { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7215  { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7216  { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7217  { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7218  { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7219  { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7220  { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7221  { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7222  { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7223  { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7224  { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7225  { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7226  { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7227  { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7228  { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7229  { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7230  { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7231  { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7232  { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7233  { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7234  { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7235  { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7236  { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7237  { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7238  { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7239  { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7240  { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7241  { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7242  { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7243  { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7244  { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7245  { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7246  { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7247  { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7248  { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7249  { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7250  { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7251  { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7252  { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7253  { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7254  { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7255  { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7256  { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7257  { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7258  { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7259  { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7260  { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7261  { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7263  };
7264  IDirect3DRMAnimation2 *animation2;
7265  IDirect3DRMAnimation *animation;
7266  IDirect3DRM3 *d3drm3;
7267  IDirect3DRM *d3drm1;
7268  IUnknown *unknown;
7269  HRESULT hr;
7270 
7271  hr = Direct3DRMCreate(&d3drm1);
7272  ok(SUCCEEDED(hr), "Failed to create d3drm instance, hr %#x.\n", hr);
7273 
7274  hr = IDirect3DRM_CreateAnimation(d3drm1, &animation);
7275  ok(SUCCEEDED(hr), "Failed to create animation hr %#x.\n", hr);
7276 
7277  hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IUnknown, (void **)&unknown);
7278  ok(SUCCEEDED(hr), "Failed to get IUnknown from animation, hr %#x.\n", hr);
7279  IDirect3DRMAnimation_Release(animation);
7280 
7281  test_qi("animation_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
7282  IUnknown_Release(unknown);
7283 
7284  hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
7285  ok(SUCCEEDED(hr), "Failed to get IDirect3DRM3, hr %#x.\n", hr);
7286 
7287  hr = IDirect3DRM3_CreateAnimation(d3drm3, &animation2);
7288  ok(SUCCEEDED(hr), "Failed to create animation hr %#x.\n", hr);
7289 
7290  hr = IDirect3DRMAnimation2_QueryInterface(animation2, &IID_IUnknown, (void **)&unknown);
7291  ok(SUCCEEDED(hr), "Failed to get IUnknown from animation, hr %#x.\n", hr);
7292  IDirect3DRMAnimation2_Release(animation2);
7293 
7294  test_qi("animation2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
7295  IUnknown_Release(unknown);
7296 
7297  IDirect3DRM3_Release(d3drm3);
7298  IDirect3DRM_Release(d3drm1);
7299 }
static void test_qi(const char *test_name, IUnknown *base_iface, REFIID refcount_iid, const struct qi_test *tests, UINT entry_count)
Definition: d3drm.c:2903
struct param_test tests[]
#define IDirect3DRMAnimation2_Release(p)
Definition: d3drmobj.h:3895
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DRM_QueryInterface(p, a, b)
Definition: d3drm.h:109
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define IDirect3DRMAnimation_QueryInterface(p, a, b)
Definition: d3drmobj.h:3809
smooth NULL
Definition: ftsmooth.c:416
#define IDirect3DRM3_Release(p)
Definition: d3drm.h:400
HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
Definition: d3drm.c:2333
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define IDirect3DRM_CreateAnimation(p, a)
Definition: d3drm.h:118
Definition: id3.c:18
#define IDirect3DRM3_CreateAnimation(p, a)
Definition: d3drm.h:407
#define IDirect3DRMAnimation_Release(p)
Definition: d3drmobj.h:3811
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
#define IDirect3DRMAnimation2_QueryInterface(p, a, b)
Definition: d3drmobj.h:3893
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_bitmap_data()

static void test_bitmap_data ( unsigned int  test_idx,
const D3DRMIMAGE img,
BOOL  upside_down,
unsigned int  w,
unsigned int  h,
BOOL  palettized 
)
static

Definition at line 5447 of file d3drm.c.

5449 {
5450  const unsigned char *data = img->buffer1;
5451  unsigned int i, j;
5452 
5453  ok(img->width == w, "Test %u: Got unexpected image width %u, expected %u.\n", test_idx, img->width, w);
5454  ok(img->height == h, "Test %u: Got unexpected image height %u, expected %u.\n", test_idx, img->height, h);
5455  ok(img->aspectx == 1, "Test %u: Got unexpected image aspectx %u.\n", test_idx, img->aspectx);
5456  ok(img->aspecty == 1, "Test %u: Got unexpected image aspecty %u.\n", test_idx, img->aspecty);
5457  ok(!img->buffer2, "Test %u: Got unexpected image buffer2 %p.\n", test_idx, img->buffer2);
5458 
5459  /* The image is palettized if the total number of colors used is <= 256. */
5460  if (w * h > 256 && !palettized)
5461  {
5462  /* D3drm aligns the 24bpp texture to 4 bytes in the buffer, with one
5463  * byte padding from 24bpp texture. */
5464  ok(img->depth == 32, "Test %u: Got unexpected image depth %u.\n", test_idx, img->depth);
5465  ok(img->rgb == TRUE, "Test %u: Got unexpected image rgb %#x.\n", test_idx, img->rgb);
5466  ok(img->bytes_per_line == w * 4, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5467  test_idx, img->bytes_per_line, w * 4);
5468  ok(img->red_mask == 0xff0000, "Test %u: Got unexpected image red mask %#x.\n", test_idx, img->red_mask);
5469  ok(img->green_mask == 0x00ff00, "Test %u: Got unexpected image green mask %#x.\n", test_idx, img->green_mask);
5470  ok(img->blue_mask == 0x0000ff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx, img->blue_mask);
5471  ok(!img->alpha_mask, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx, img->alpha_mask);
5472  ok(!img->palette_size, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
5473  ok(!img->palette, "Test %u: Got unexpected image palette %p.\n", test_idx, img->palette);
5474  for (i = 0; i < h; ++i)
5475  {
5476  for (j = 0; j < w; ++j)
5477  {
5478  const unsigned char *ptr = &data[i * img->bytes_per_line + j * 4];
5479  unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
5480 
5481  if (ptr[0] != idx % 251 || ptr[1] != idx % 239 || ptr[2] != idx % 247 || ptr[3] != 0xff)
5482  {
5483  ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
5484  "expected 0x%02x%02x%02x%02x.\n", test_idx, ptr[0], ptr[1], ptr[2], ptr[3],
5485  j, i, idx % 251, idx % 239, idx % 247, 0xff);
5486  return;
5487  }
5488  }
5489  }
5490  return;
5491  }
5492 
5493  ok(img->depth == 8, "Test %u: Got unexpected image depth %u.\n", test_idx, img->depth);
5494  ok(!img->rgb, "Test %u: Got unexpected image rgb %#x.\n", test_idx, img->rgb);
5495  ok(img->red_mask == 0xff, "Test %u: Got unexpected image red mask %#x.\n", test_idx, img->red_mask);
5496  ok(img->green_mask == 0xff, "Test %u: Got unexpected image green mask %#x.\n", test_idx, img->green_mask);
5497  ok(img->blue_mask == 0xff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx, img->blue_mask);
5498  ok(!img->alpha_mask, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx, img->alpha_mask);
5499  ok(!!img->palette, "Test %u: Got unexpected image palette %p.\n", test_idx, img->palette);
5500  if (!palettized)
5501  {
5502  /* In this case, bytes_per_line is aligned to the next multiple of
5503  * 4 from width. */
5504  ok(img->bytes_per_line == ((w + 3) & ~3), "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5505  test_idx, img->bytes_per_line, (w + 3) & ~3);
5506  ok(img->palette_size == w * h, "Test %u: Got unexpected palette size %u, expected %u.\n",
5507  test_idx, img->palette_size, w * h);
5508  for (i = 0; i < img->palette_size; ++i)
5509  {
5510  unsigned int idx = upside_down ? (h - 1) * w - i + (i % w) * 2 : i;
5511  ok(img->palette[i].red == idx % 251
5512  && img->palette[i].green == idx % 239 && img->palette[i].blue == idx % 247,
5513  "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
5514  test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
5515  ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
5516  "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
5517  test_idx, i, img->palette[i].flags);
5518  }
5519  for (i = 0; i < h; ++i)
5520  {
5521  for (j = 0; j < w; ++j)
5522  {
5523  if (data[i * img->bytes_per_line + j] != i * w + j)
5524  {
5525  ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
5526  test_idx, data[i * img->bytes_per_line + j], j, i, i * w + j);
5527  return;
5528  }
5529  }
5530  }
5531  return;
5532  }
5533 
5534  /* bytes_per_line is not always aligned by d3drm depending on the
5535  * format. */
5536  ok(img->bytes_per_line == w, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5537  test_idx, img->bytes_per_line, w);
5538  ok(img->palette_size == 256, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
5539  for (i = 0; i < 256; ++i)
5540  {
5541  ok(img->palette[i].red == i && img->palette[i].green == i && img->palette[i].blue == i,
5542  "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
5543  test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
5544  ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
5545  "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
5546  test_idx, i, img->palette[i].flags);
5547  }
5548  for (i = 0; i < h; ++i)
5549  {
5550  for (j = 0; j < w; ++j)
5551  {
5552  unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
5553  if (data[i * img->bytes_per_line + j] != idx % 256)
5554  {
5555  ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
5556  test_idx, data[i * img->bytes_per_line + j], j, i, idx % 256);
5557  return;
5558  }
5559  }
5560  }
5561 }
#define TRUE
Definition: types.h:120
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
unsigned int idx
Definition: utils.c:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLint GLvoid * img
Definition: gl.h:1956
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_load_texture().

◆ test_class_name_()

static void test_class_name_ ( unsigned int  line,
IDirect3DRMObject *  object,
const char name 
)
static

Definition at line 96 of file d3drm.c.

97 {
98  char cname[64] = {0};
99  DWORD size, size2;
100  HRESULT hr;
101 
102  hr = IDirect3DRMObject_GetClassName(object, NULL, cname);
103  ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
105  ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
106 
107  size = 0;
109  ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname size, hr %#x.\n", hr);
110  ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
111 
112  size = size2 = !!*name;
113  hr = IDirect3DRMObject_GetClassName(object, &size, cname);
114  ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
115  ok_(__FILE__, line)(size == size2, "Got size %u.\n", size);
116 
117  size = sizeof(cname);
118  hr = IDirect3DRMObject_GetClassName(object, &size, cname);
119  ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#x.\n", hr);
120  ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
121  ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
122 
123  size = strlen(name) + 1;
124  hr = IDirect3DRMObject_GetClassName(object, &size, cname);
125  ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#x.\n", hr);
126  ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
127  ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
128 
129  size = strlen(name);
130  strcpy(cname, "XXX");
131  hr = IDirect3DRMObject_GetClassName(object, &size, cname);
132  ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
133  ok_(__FILE__, line)(size == strlen(name), "Wrong classname size: %u.\n", size);
134  ok_(__FILE__, line)(!strcmp(cname, "XXX"), "Expected unchanged buffer, but got \"%s\".\n", cname);
135 }
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define IDirect3DRMObject_GetClassName(p, a, b)
Definition: d3drmobj.h:229
#define IDirect3DRMViewport_GetClassName(p, a, b)
Definition: d3drmobj.h:856
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok_(x1, x2)
Definition: atltest.h:61
GLuint const GLchar * name
Definition: glext.h:6031

◆ test_create_device_from_clipper1()

static void test_create_device_from_clipper1 ( void  )
static

Definition at line 3299 of file d3drm.c.

3300 {
3301  DDSCAPS caps = { DDSCAPS_ZBUFFER };
3302  IDirect3DRM *d3drm1 = NULL;
3303  IDirectDraw *ddraw = NULL;
3304  IUnknown *unknown = NULL;
3305  IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
3306  IDirect3DDevice *d3ddevice1 = NULL;
3307  IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
3308  IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
3309  IDirectDrawSurface7 *surface7 = NULL;
3310  DDSURFACEDESC desc, surface_desc;
3311  DWORD expected_flags, ret_val;
3312  HWND window;
3313  GUID driver = IID_IDirect3DRGBDevice;
3314  HRESULT hr;
3315  ULONG ref1, ref2, cref1, cref2;
3316  RECT rc;
3317 
3318  window = create_window();
3319  GetClientRect(window, &rc);
3320  hr = DirectDrawCreateClipper(0, &clipper, NULL);
3321  ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
3322  hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
3323  ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
3324 
3325  hr = Direct3DRMCreate(&d3drm1);
3326  ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
3327  ref1 = get_refcount((IUnknown *)d3drm1);
3328  cref1 = get_refcount((IUnknown *)clipper);
3329 
3330  hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 0, 0, &device1);
3331  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3332  ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
3333 
3334  /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3335  hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, NULL, &driver, 300, 200, &device1);
3336  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3337 
3338  hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 300, 200, NULL);
3339  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3340 
3341  hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 300, 200, &device1);
3342  ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr);
3343  ref2 = get_refcount((IUnknown *)d3drm1);
3344  ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
3345  cref2 = get_refcount((IUnknown *)clipper);
3346  ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
3347  ret_val = IDirect3DRMDevice_GetWidth(device1);
3348  ok(ret_val == 300, "Expected device width = 300, got %u.\n", ret_val);
3349  ret_val = IDirect3DRMDevice_GetHeight(device1);
3350  ok(ret_val == 200, "Expected device height == 200, got %u.\n", ret_val);
3351 
3352  /* Fetch immediate mode device in order to access render target */
3353  hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
3354  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
3355 
3356  hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
3357  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3358 
3359  hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
3360  ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
3361 
3362  /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3363  hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
3364  ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr);
3365  IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
3366  hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
3367  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3368  IUnknown_Release(unknown);
3369  hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
3370  NULL, &d3drm_primary, surface_callback);
3371  ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
3372  ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
3373  hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
3374  ok(hr == DD_OK, "Cannot get attached clipper from primary surface (hr = %x).\n", hr);
3375  ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
3376 
3377  IDirectDrawClipper_Release(d3drm_clipper);
3378  IDirectDrawSurface_Release(d3drm_primary);
3379  IDirectDrawSurface7_Release(surface7);
3380  IDirectDraw_Release(ddraw);
3381 
3382  /* Check properties of render target and depth surface */
3383  surface_desc.dwSize = sizeof(surface_desc);
3384  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3385  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3386 
3387  ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3388  surface_desc.dwWidth, surface_desc.dwHeight);
3389  ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
3390  "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
3391  expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
3392  ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
3393 
3395  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3396  desc.dwSize = sizeof(desc);
3397  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3398  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3399  ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %u bpp, got %u bpp.\n",
3400  surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
3401 
3402  hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
3403  ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
3404 
3405  desc.dwSize = sizeof(desc);
3406  hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
3407  ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
3408 
3409  ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3410  desc.dwWidth, desc.dwHeight);
3411  ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
3413  ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
3414  ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc.dwZBufferBitDepth);
3415  ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
3416 
3417  /* Release old objects and check refcount of device and clipper */
3418  IDirectDrawSurface_Release(ds);
3419  ds = NULL;
3420  IDirectDrawSurface_Release(surface);
3421  surface = NULL;
3422  IDirect3DDevice_Release(d3ddevice1);
3423  d3ddevice1 = NULL;
3424  IDirect3DRMDevice_Release(device1);
3425  ref2 = get_refcount((IUnknown *)d3drm1);
3426  ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
3427  cref2 = get_refcount((IUnknown *)clipper);
3428  ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
3429 
3430  /* Test if render target format follows the screen format */
3431  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3432  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3433  hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
3434  ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
3435 
3436  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3437  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3438  ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
3439 
3440  hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1);
3441  ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr);
3442 
3443  hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
3444  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
3445 
3446  hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
3447  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3448 
3449  surface_desc.dwSize = sizeof(surface_desc);
3450  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3451  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3452  todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
3453  surface_desc.ddpfPixelFormat.dwRGBBitCount);
3454 
3455  hr = IDirectDraw2_RestoreDisplayMode(ddraw);
3456  ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
3457 
3458  if (ds)
3459  IDirectDrawSurface_Release(ds);
3460  IDirectDrawSurface_Release(surface);
3461  IDirect3DDevice_Release(d3ddevice1);
3462  IDirect3DRMDevice_Release(device1);
3463  IDirect3DRM_Release(d3drm1);
3464  IDirectDrawClipper_Release(clipper);
3465  IDirectDraw_Release(ddraw);
3467 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
#define IDirect3DDevice_Release(p)
Definition: d3d.h:966
HRESULT hr
Definition: shlfolder.c:183
struct @1609::@1610 driver
#define ds
Definition: i386-dis.c:434
static ULONG get_refcount(IUnknown *object)
Definition: d3drm.c:39
#define DDERR_NOCLIPPERATTACHED
Definition: ddraw.h:142
HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter)
Definition: main.c:55
LONG right
Definition: windef.h:293
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND create_window(void)
Definition: d3drm.c:85
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:267
DWORD IDirectDrawSurface7
Definition: vmrender.idl:20
#define DDSD_HEIGHT
Definition: ddraw.h:209
HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
Definition: d3drm.c:2333
LONG HRESULT
Definition: typedefs.h:77
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DDENUMSURFACES_DOESEXIST
Definition: ddraw.h:525
Definition: id3.c:18
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496
#define todo_wine
Definition: test.h:154
#define IDirect3DRMDevice_GetHeight(p)
Definition: d3drmobj.h:435
#define IDirect3DRMDevice_GetWidth(p)
Definition: d3drmobj.h:436
static HRESULT CALLBACK surface_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
Definition: d3drm.c:3285
static IHTMLWindow2 * window
Definition: events.c:77
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:213
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DDENUMSURFACES_ALL
Definition: ddraw.h:521
#define IDirect3DRMDevice_GetDirect3DDevice(p, a)
Definition: d3drmobj.h:442
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:294
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
#define IDirect3DDevice_QueryInterface(p, a, b)
Definition: d3d.h:964
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define IDirect3DRM_CreateDeviceFromClipper(p, a, b, c, d, e)
Definition: d3drm.h:127
#define IDirect3DRMDevice_Release(p)
Definition: d3drmobj.h:409
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DDSD_PITCH
Definition: ddraw.h:211

Referenced by START_TEST().

◆ test_create_device_from_clipper2()

static void test_create_device_from_clipper2 ( void  )
static

Definition at line 3469 of file d3drm.c.

3470 {
3471  DDSCAPS caps = { DDSCAPS_ZBUFFER };
3472  IDirect3DRM *d3drm1 = NULL;
3473  IDirect3DRM2 *d3drm2 = NULL;
3474  IDirectDraw *ddraw = NULL;
3475  IUnknown *unknown = NULL;
3476  IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
3477  IDirect3DDevice2 *d3ddevice2 = NULL;
3478  IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
3479  IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
3480  IDirectDrawSurface7 *surface7 = NULL;
3481  DDSURFACEDESC desc, surface_desc;
3482  DWORD expected_flags, ret_val;
3483  HWND window;
3484  GUID driver = IID_IDirect3DRGBDevice;
3485  HRESULT hr;
3486  ULONG ref1, ref2, ref3, cref1, cref2;
3487  RECT rc;
3488 
3489  window = create_window();
3490  GetClientRect(window, &rc);
3491  hr = DirectDrawCreateClipper(0, &clipper, NULL);
3492  ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
3493  hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
3494  ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
3495 
3496  hr = Direct3DRMCreate(&d3drm1);
3497  ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
3498  ref1 = get_refcount((IUnknown *)d3drm1);
3499  cref1 = get_refcount((IUnknown *)clipper);
3500 
3501  hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
3502  ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr);
3503  ref2 = get_refcount((IUnknown *)d3drm2);
3504 
3505  hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 0, 0, &device2);
3506  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3507  ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
3508 
3509  /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3510  hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, NULL, &driver, 300, 200, &device2);
3511  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3512 
3513  hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, NULL);
3514  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3515 
3516  hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, &device2);
3517  ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
3518  ref3 = get_refcount((IUnknown *)d3drm1);
3519  ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
3520  ref3 = get_refcount((IUnknown *)d3drm2);
3521  ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
3522  cref2 = get_refcount((IUnknown *)clipper);
3523  ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
3524  ret_val = IDirect3DRMDevice2_GetWidth(device2);
3525  ok(ret_val == 300, "Expected device width = 300, got %u.\n", ret_val);
3526  ret_val = IDirect3DRMDevice2_GetHeight(device2);
3527  ok(ret_val == 200, "Expected device height == 200, got %u.\n", ret_val);
3528 
3529  /* Fetch immediate mode device in order to access render target */
3530  hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
3531  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
3532 
3533  hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
3534  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3535 
3536  hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
3537  ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
3538 
3539  /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3540  hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
3541  ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr);
3542  IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
3543  hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
3544  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3545  IUnknown_Release(unknown);
3546  hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
3547  NULL, &d3drm_primary, surface_callback);
3548  ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
3549  ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
3550  hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
3551  ok(hr == DD_OK, "Cannot get attached clipper from primary surface (hr = %x).\n", hr);
3552  ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
3553 
3554  IDirectDrawClipper_Release(d3drm_clipper);
3555  IDirectDrawSurface_Release(d3drm_primary);
3556  IDirectDrawSurface7_Release(surface7);
3557  IDirectDraw_Release(ddraw);
3558 
3559  /* Check properties of render target and depth surface */
3560  surface_desc.dwSize = sizeof(surface_desc);
3561  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3562  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3563 
3564  ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3565  surface_desc.dwWidth, surface_desc.dwHeight);
3566  ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
3567  "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
3568  expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
3569  ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
3570 
3572  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3573  desc.dwSize = sizeof(desc);
3574  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3575  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3576  ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %u bpp, got %u bpp.\n",
3577  surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
3578 
3579  hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
3580  ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
3581 
3582  desc.dwSize = sizeof(desc);
3583  hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
3584  ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
3585 
3586  ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3587  desc.dwWidth, desc.dwHeight);
3588  ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
3590  ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
3591  ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc.dwZBufferBitDepth);
3592  ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
3593 
3594  /* Release old objects and check refcount of device and clipper */
3595  IDirectDrawSurface_Release(ds);
3596  ds = NULL;
3597  IDirectDrawSurface_Release(surface);
3598  surface = NULL;
3599  IDirect3DDevice2_Release(d3ddevice2);
3600  d3ddevice2 = NULL;
3601  IDirect3DRMDevice2_Release(device2);
3602  ref3 = get_refcount((IUnknown *)d3drm1);
3603  ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
3604  ref3 = get_refcount((IUnknown *)d3drm2);
3605  ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
3606  cref2 = get_refcount((IUnknown *)clipper);
3607  ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
3608 
3609  /* Test if render target format follows the screen format */
3610  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3611  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3612  hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
3613  ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
3614 
3615  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3616  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3617  ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
3618 
3619  hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, rc.right, rc.bottom, &device2);
3620  ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
3621 
3622  hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
3623  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
3624 
3625  hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
3626  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3627 
3628  surface_desc.dwSize = sizeof(surface_desc);
3629  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3630  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3631  todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
3632  surface_desc.ddpfPixelFormat.dwRGBBitCount);
3633 
3634  hr = IDirectDraw2_RestoreDisplayMode(ddraw);
3635  ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
3636 
3637  IDirectDrawSurface_Release(surface);
3638  IDirect3DDevice2_Release(d3ddevice2);
3639  IDirect3DRMDevice2_Release(device2);
3640  IDirect3DRM2_Release(d3drm2);
3641  IDirect3DRM_Release(d3drm1);
3642  IDirectDrawClipper_Release(clipper);
3643  IDirectDraw_Release(ddraw);
3645 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
#define IDirect3DRMDevice2_GetDirect3DDevice2(p, a)
Definition: d3drmobj.h:581
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DRM_QueryInterface(p, a, b)
Definition: d3drm.h:109
struct @1609::@1610 driver
#define IDirect3DRMDevice2_GetHeight(p)
Definition: d3drmobj.h:568
#define ds
Definition: i386-dis.c:434
static ULONG get_refcount(IUnknown *object)
Definition: d3drm.c:39
#define DDERR_NOCLIPPERATTACHED
Definition: ddraw.h:142
HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter)
Definition: main.c:55
LONG right
Definition: windef.h:293
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND create_window(void)
Definition: d3drm.c:85
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define IDirect3DRM2_Release(p)
Definition: d3drm.h:252
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:267
#define IDirect3DRMDevice2_Release(p)
Definition: d3drmobj.h:542
DWORD IDirectDrawSurface7
Definition: vmrender.idl:20
#define DDSD_HEIGHT
Definition: ddraw.h:209
HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
Definition: d3drm.c:2333
LONG HRESULT
Definition: typedefs.h:77
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DDevice2_GetRenderTarget(p, a)
Definition: d3d.h:1079
#define DDENUMSURFACES_DOESEXIST
Definition: ddraw.h:525
#define IDirect3DRMDevice2_GetWidth(p)
Definition: d3drmobj.h:569
Definition: id3.c:18
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496
#define todo_wine
Definition: test.h:154
static HRESULT CALLBACK surface_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
Definition: d3drm.c:3285
static IHTMLWindow2 * window
Definition: events.c:77
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:213
#define IDirect3DRM2_CreateDeviceFromClipper(p, a, b, c, d, e)
Definition: d3drm.h:268
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DDENUMSURFACES_ALL
Definition: ddraw.h:521
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:294
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define IDirect3DDevice2_Release(p)
Definition: d3d.h:1064
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DDSD_PITCH
Definition: ddraw.h:211

Referenced by START_TEST().

◆ test_create_device_from_clipper3()

static void test_create_device_from_clipper3 ( void  )
static

Definition at line 3647 of file d3drm.c.

3648 {
3649  DDSCAPS caps = { DDSCAPS_ZBUFFER };
3650  IDirect3DRM *d3drm1 = NULL;
3651  IDirect3DRM3 *d3drm3 = NULL;
3652  IDirectDraw *ddraw = NULL;
3653  IUnknown *unknown = NULL;
3654  IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
3655  IDirect3DDevice2 *d3ddevice2 = NULL;
3656  IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
3657  IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
3658  IDirectDrawSurface7 *surface7 = NULL;
3659  DDSURFACEDESC desc, surface_desc;
3660  DWORD expected_flags, ret_val;
3661  HWND window;
3662  GUID driver = IID_IDirect3DRGBDevice;
3663  HRESULT hr;
3664  ULONG ref1, ref2, ref3, cref1, cref2;
3665  RECT rc;
3666 
3667  window = create_window();
3668  GetClientRect(window, &rc);
3669  hr = DirectDrawCreateClipper(0, &clipper, NULL);
3670  ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
3671  hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
3672  ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
3673 
3674  hr = Direct3DRMCreate(&d3drm1);
3675  ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
3676  ref1 = get_refcount((IUnknown *)d3drm1);
3677  cref1 = get_refcount((IUnknown *)clipper);
3678 
3679  hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
3680  ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
3681  ref2 = get_refcount((IUnknown *)d3drm3);
3682 
3683  hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 0, 0, &device3);
3684  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3685  ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
3686 
3687  /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3688  hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, NULL, &driver, 300, 200, &device3);
3689  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3690 
3691  hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 300, 200, NULL);
3692  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3693 
3694  hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 300, 200, &device3);
3695  ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr);
3696  ref3 = get_refcount((IUnknown *)d3drm1);
3697  ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
3698  ref3 = get_refcount((IUnknown *)d3drm3);
3699  ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
3700  cref2 = get_refcount((IUnknown *)clipper);
3701  ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
3702  ret_val = IDirect3DRMDevice3_GetWidth(device3);
3703  ok(ret_val == 300, "Expected device width = 300, got %u.\n", ret_val);
3704  ret_val = IDirect3DRMDevice3_GetHeight(device3);
3705  ok(ret_val == 200, "Expected device height == 200, got %u.\n", ret_val);
3706 
3707  /* Fetch immediate mode device in order to access render target */
3708  hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
3709  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
3710 
3711  hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
3712  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3713 
3714  hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
3715  ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
3716 
3717  /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3718  hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
3719  ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr);
3720  IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
3721  hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
3722  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3723  IUnknown_Release(unknown);
3724  hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
3725  NULL, &d3drm_primary, surface_callback);
3726  ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
3727  ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
3728  hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
3729  ok(hr == DD_OK, "Cannot get attached clipper from primary surface (hr = %x).\n", hr);
3730  ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
3731 
3732  IDirectDrawClipper_Release(d3drm_clipper);
3733  IDirectDrawSurface_Release(d3drm_primary);
3734  IDirectDrawSurface7_Release(surface7);
3735  IDirectDraw_Release(ddraw);
3736 
3737  /* Check properties of render target and depth surface */
3738  surface_desc.dwSize = sizeof(surface_desc);
3739  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3740  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3741 
3742  ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3743  surface_desc.dwWidth, surface_desc.dwHeight);
3744  ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
3745  "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
3746  expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
3747  ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
3748 
3750  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3751  desc.dwSize = sizeof(desc);
3752  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3753  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3754  ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %u bpp, got %u bpp.\n",
3755  surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
3756 
3757  hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
3758  ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
3759 
3760  desc.dwSize = sizeof(desc);
3761  hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
3762  ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
3763 
3764  ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3765  desc.dwWidth, desc.dwHeight);
3766  ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
3768  ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
3769  ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc.dwZBufferBitDepth);
3770  ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
3771 
3772  /* Release old objects and check refcount of device and clipper */
3773  IDirectDrawSurface_Release(ds);
3774  ds = NULL;
3775  IDirectDrawSurface_Release(surface);
3776  surface = NULL;
3777  IDirect3DDevice2_Release(d3ddevice2);
3778  d3ddevice2 = NULL;
3779  IDirect3DRMDevice3_Release(device3);
3780  ref3 = get_refcount((IUnknown *)d3drm1);
3781  ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
3782  ref3 = get_refcount((IUnknown *)d3drm3);
3783  ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
3784  cref2 = get_refcount((IUnknown *)clipper);
3785  ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
3786 
3787  /* Test if render target format follows the screen format */
3788  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3789  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3790  hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
3791  ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
3792 
3793  hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3794  ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3795  ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
3796 
3797  hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
3798  ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr);
3799 
3800  hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
3801  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
3802 
3803  hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
3804  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3805 
3806  surface_desc.dwSize = sizeof(surface_desc);
3807  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3808  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3809  todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
3810  surface_desc.ddpfPixelFormat.dwRGBBitCount);
3811 
3812  hr = IDirectDraw2_RestoreDisplayMode(ddraw);
3813  ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
3814 
3815  IDirectDrawSurface_Release(surface);
3816  IDirect3DDevice2_Release(d3ddevice2);
3817  IDirect3DRMDevice3_Release(device3);
3818  IDirect3DRM3_Release(d3drm3);
3819  IDirect3DRM_Release(d3drm1);
3820  IDirectDrawClipper_Release(clipper);
3821  IDirectDraw_Release(ddraw);
3823 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DRMDevice3_GetWidth(p)
Definition: d3drmobj.h:720
#define IDirect3DRM_QueryInterface(p, a, b)
Definition: d3drm.h:109
struct @1609::@1610 driver
#define ds
Definition: i386-dis.c:434
static ULONG get_refcount(IUnknown *object)
Definition: d3drm.c:39
#define DDERR_NOCLIPPERATTACHED
Definition: ddraw.h:142
HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter)
Definition: main.c:55
LONG right
Definition: windef.h:293
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND create_window(void)
Definition: d3drm.c:85
#define IDirect3DRMDevice3_Release(p)
Definition: d3drmobj.h:693
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:267
#define IDirect3DRM3_Release(p)
Definition: d3drm.h:400
DWORD IDirectDrawSurface7
Definition: vmrender.idl:20
#define DDSD_HEIGHT
Definition: ddraw.h:209
HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
Definition: d3drm.c:2333
LONG HRESULT
Definition: typedefs.h:77
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DDevice2_GetRenderTarget(p, a)
Definition: d3d.h:1079
#define DDENUMSURFACES_DOESEXIST
Definition: ddraw.h:525
Definition: id3.c:18
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496
#define todo_wine
Definition: test.h:154
#define IDirect3DRMDevice3_GetDirect3DDevice2(p, a)
Definition: d3drmobj.h:732
static HRESULT CALLBACK surface_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
Definition: d3drm.c:3285
static IHTMLWindow2 * window
Definition: events.c:77
#define IDirect3DRMDevice3_GetHeight(p)
Definition: d3drmobj.h:719
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:213
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define IDirect3DRM3_CreateDeviceFromClipper(p, a, b, c, d, e)
Definition: d3drm.h:416
#define DDENUMSURFACES_ALL
Definition: ddraw.h:521
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:294
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define IDirect3DDevice2_Release(p)
Definition: d3d.h:1064
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DDSD_PITCH
Definition: ddraw.h:211

Referenced by START_TEST().

◆ test_create_device_from_d3d1()

static void test_create_device_from_d3d1 ( void  )
static

Definition at line 4474 of file d3drm.c.

4475 {
4476  IDirectDraw *ddraw1 = NULL, *temp_ddraw1;
4477  IDirect3D *d3d1 = NULL, *temp_d3d1;
4478  IDirect3DRM *d3drm1 = NULL;
4479  IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
4480  IDirect3DRMDevice2 *device2;
4481  IDirect3DRMDevice3 *device3;
4482  IDirect3DDevice *d3ddevice1 = NULL, *d3drm_d3ddevice1 = NULL, *temp_d3ddevice1;
4483  IDirect3DDevice2 *d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
4484  IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
4485  DWORD expected_flags, ret_val;
4486  DDSCAPS caps = { DDSCAPS_ZBUFFER };
4488  RECT rc;
4489  HWND window;
4490  ULONG ref1, ref2, ref3, ref4, device_ref1, device_ref2, d3d_ref1, d3d_ref2;
4491  HRESULT hr;
4492 
4493  hr = DirectDrawCreate(NULL, &ddraw1, NULL);
4494  ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
4495 
4496  window = create_window();
4497  GetClientRect(window, &rc);
4498 
4499  hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D, (void **)&d3d1);
4500  ok(hr == DD_OK, "Cannot get IDirect3D2 interface (hr = %x).\n", hr);
4501  d3d_ref1 = get_refcount((IUnknown *)d3d1);
4502 
4503  /* Create the immediate mode device */
4504  d3ddevice1 = create_device1(ddraw1, window, &ds);
4505  if (d3ddevice1 == NULL)
4506  {
4507  win_skip("Cannot create IM device, skipping tests.\n");
4508  IDirect3D_Release(d3d1);
4509  IDirectDraw_Release(ddraw1);
4510  return;
4511  }
4512  device_ref1 = get_refcount((IUnknown *)d3ddevice1);
4513 
4514  hr = Direct3DRMCreate(&d3drm1);
4515  ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
4516  ref1 = get_refcount((IUnknown *)d3drm1);
4517 
4518  hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, NULL, d3ddevice1, &device1);
4519  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4520  ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
4521  hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, NULL, &device1);
4522  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4523  hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, NULL);
4524  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4525 
4526  hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, &device1);
4527  ok(hr == DD_OK, "Failed to create IDirect3DRMDevice interface (hr = %x)\n", hr);
4528  ref2 = get_refcount((IUnknown *)d3drm1);
4529  ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
4530  device_ref2 = get_refcount((IUnknown *)d3ddevice1);
4531  ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2);
4532  d3d_ref2 = get_refcount((IUnknown *)d3d1);
4533  ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1, d3d_ref2);
4534  ret_val = IDirect3DRMDevice_GetWidth(device1);
4535  ok(ret_val == rc.right, "Expected device width = 300, got %u.\n", ret_val);
4536  ret_val = IDirect3DRMDevice_GetHeight(device1);
4537  ok(ret_val == rc.bottom, "Expected device height == 200, got %u.\n", ret_val);
4538 
4539  hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2);
4540  ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr);
4541  hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4542  ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got %#x.\n", hr);
4543  ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
4544  IDirect3DRMDevice2_Release(device2);
4545 
4546  d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
4547  hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3);
4548  ok(hr == DD_OK, "Cannot get IDirect3DRMDevice3 Interface (hr = %x).\n", hr);
4549  hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4550  ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
4551  ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
4552  IDirect3DRMDevice3_Release(device3);
4553 
4554  hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4555  NULL, &surface, surface_callback);
4556  ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
4557  ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
4558 
4559  hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
4560  ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
4561  ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice1, d3drm_d3ddevice1);
4562 
4563  /* Check properties of render target and depth surfaces */
4564  hr = IDirect3DDevice_QueryInterface(d3drm_d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
4565  ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
4566 
4567  memset(&desc, 0, sizeof(desc));
4568  desc.dwSize = sizeof(desc);
4569  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
4570  ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
4571 
4572  ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4573  rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
4575  "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, desc.ddsCaps.dwCaps);
4576  expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
4577  ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
4578 
4579  hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
4580  ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
4581  ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
4582 
4583  desc.dwSize = sizeof(desc);
4584  hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4585  ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
4586 
4587  ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4588  rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
4589  ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
4591  ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
4592 
4593  IDirectDrawSurface_Release(d3drm_ds);
4594  IDirectDrawSurface_Release(ds);
4595  IDirectDrawSurface_Release(surface);
4596  IDirect3DDevice_Release(d3drm_d3ddevice1);
4597  IDirect3DRMDevice_Release(device1);
4598  ref2 = get_refcount((IUnknown *)d3drm1);
4599  ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
4600  device_ref2 = get_refcount((IUnknown *)d3ddevice1);
4601  ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2);
4602 
4603  /* InitFromD3D tests */
4604  hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice, (void **)&device1);
4605  ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr);
4606 
4607  hr = IDirect3DRMDevice_InitFromD3D(device1, NULL, d3ddevice1);
4608  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
4609  hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, NULL);
4610  ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
4611 
4612  hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
4613  ok(SUCCEEDED(hr), "Failed to initialise IDirect3DRMDevice interface (hr = %#x)\n", hr);
4614  ref2 = get_refcount((IUnknown *)d3drm1);
4615  ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
4616  device_ref2 = get_refcount((IUnknown *)d3ddevice1);
4617  ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4618  device_ref1, device_ref2);
4619  d3d_ref2 = get_refcount((IUnknown *)d3d1);
4620  ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1, d3d_ref2);
4621  ret_val = IDirect3DRMDevice_GetWidth(device1);
4622  ok(ret_val == rc.right, "Expected device width = 300, got %u.\n", ret_val);
4623  ret_val = IDirect3DRMDevice_GetHeight(device1);
4624  ok(ret_val == rc.bottom, "Expected device height == 200, got %u.\n", ret_val);
4625 
4626  hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
4627  ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
4628  ref3 = get_refcount((IUnknown *)d3drm1);
4629  ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
4630  ref3 = get_refcount((IUnknown *)d3ddevice1);
4631  ok(ref3 > device_ref2, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3, device_ref2);
4632  ref3 = get_refcount((IUnknown *)d3d1);
4633  ok(ref3 > d3d_ref2, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3, d3d_ref2);
4634  /* Release leaked references */
4635  while (IDirect3DRM_Release(d3drm1) > ref2);
4636  while (IDirect3DDevice_Release(d3ddevice1) > device_ref2);
4637  while (IDirect3D_Release(d3d1) > d3d_ref2);
4638 
4639  hr = DirectDrawCreate(NULL, &temp_ddraw1, NULL);
4640  ok(SUCCEEDED(hr), "Cannot get IDirectDraw interface (hr = %#x).\n", hr);
4641  ref4 = get_refcount((IUnknown *)temp_ddraw1);
4642 
4643  hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirect3D, (void **)&temp_d3d1);
4644  ok(SUCCEEDED(hr), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr);
4645  temp_d3ddevice1 = create_device1(temp_ddraw1, window, &surface);
4646  hr = IDirect3DRMDevice_InitFromD3D(device1, temp_d3d1, temp_d3ddevice1);
4647  ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
4648  ref3 = get_refcount((IUnknown *)d3drm1);
4649  ok(ref3 > ref2, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
4650  ref3 = get_refcount((IUnknown *)temp_d3ddevice1);
4651  ok(ref3 == device_ref2, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3, device_ref2);
4652  ref3 = get_refcount((IUnknown *)temp_d3d1);
4653  todo_wine ok(ref3 < d3d_ref2, "Expected ref3 < d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3, d3d_ref2);
4654  /* Release leaked references */
4655  while (IDirect3DRM_Release(d3drm1) > ref2);
4656  while (IDirect3DDevice_Release(temp_d3ddevice1) > 0);
4657  while (IDirect3D_Release(temp_d3d1) > ref4);
4658  IDirectDrawSurface_Release(surface);
4659  IDirectDraw_Release(temp_ddraw1);
4660 
4661  d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
4662  hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2);
4663  ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr);
4664  hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4665  ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got %#x.\n", hr);
4666  ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
4667  IDirect3DRMDevice2_Release(device2);
4668 
4669  d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
4670  hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3);
4671  ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 Interface (hr = %#x).\n", hr);
4672  hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4673  ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
4674  ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
4675  IDirect3DRMDevice3_Release(device3);
4676 
4677  surface = NULL;
4678  hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4679  NULL, &surface, surface_callback);
4680  ok(SUCCEEDED(hr), "Failed to enumerate surfaces (hr = %#x).\n", hr);
4681  ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
4682 
4683  hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
4684  ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice interface (hr = %#x).\n", hr);
4685  ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode device created == %p, got %p.\n",
4686  d3ddevice1, d3drm_d3ddevice1);
4687 
4688  /* Check properties of render target and depth surfaces */
4689  hr = IDirect3DDevice_QueryInterface(d3drm_d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
4690  ok(SUCCEEDED(hr), "Cannot get surface to the render target (hr = %#x).\n", hr);
4691 
4692  memset(&desc, 0, sizeof(desc));
4693  desc.dwSize = sizeof(desc);
4694  hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
4695  ok(SUCCEEDED(hr), "Cannot get surface desc structure (hr = %#x).\n", hr);
4696 
4697  ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4698  rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
4700  "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, desc.ddsCaps.dwCaps);
4701  expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
4702  ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
4703 
4704  hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
4705  ok(SUCCEEDED(hr), "Cannot get attached depth surface (hr = %x).\n",