ReactOS 0.4.15-dev-5895-g2687c1b
d3drm.c File Reference
#include <limits.h>
#include <d3d.h>
#include <initguid.h>
#include <d3drm.h>
#include <d3drmwin.h>
#include <math.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 _USE_MATH_DEFINES
 
#define CHECK_REFCOUNT(obj, rc)
 
#define expect_matrix(m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u)    expect_matrix_(__LINE__, m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u)
 
#define expect_vector(v, x, y, z, u)   expect_vector_(__LINE__, v, x, y, z, u)
 
#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 expect_matrix_ (unsigned int line, D3DRMMATRIX4D m, float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44, unsigned int ulps)
 
static void expect_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 void frame_set_transform (IDirect3DRMFrame *frame, float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
 
static void set_vector (D3DVECTOR *v, float x, float y, float z)
 
static void matrix_sanitise (D3DRMMATRIX4D m)
 
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 void test_create_device_1 (void)
 
static void test_create_device_2 (void)
 
static void test_create_device_3 (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

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 25 of file d3drm.c.

◆ 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:41

Definition at line 34 of file d3drm.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file d3drm.c.

◆ expect_matrix

#define expect_matrix (   m,
  m11,
  m12,
  m13,
  m14,
  m21,
  m22,
  m23,
  m24,
  m31,
  m32,
  m33,
  m34,
  m41,
  m42,
  m43,
  m44,
  u 
)     expect_matrix_(__LINE__, m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u)

Definition at line 63 of file d3drm.c.

◆ expect_vector

#define expect_vector (   v,
  x,
  y,
  z,
  u 
)    expect_vector_(__LINE__, v, x, y, z, u)

Definition at line 89 of file d3drm.c.

◆ test_class_name

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

Definition at line 159 of file d3drm.c.

◆ test_object_name

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

Definition at line 201 of file d3drm.c.

◆ vector_eq

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

Definition at line 100 of file d3drm.c.

Function Documentation

◆ clear_depth_surface()

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

Definition at line 6708 of file d3drm.c.

6709{
6710 HRESULT hr;
6711 DDBLTFX fx;
6712
6713 memset(&fx, 0, sizeof(fx));
6714 fx.dwSize = sizeof(fx);
6715 U5(fx).dwFillDepth = value;
6716
6717 hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
6718 ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
6719}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define DDBLT_WAIT
Definition: ddraw.h:569
#define DDBLT_DEPTHFILL
Definition: ddraw.h:570
#define U5(x)
Definition: test.h:203
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
GLfixed fx
Definition: tritemp.h:484
Definition: pdh_main.c:94

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 6696 of file d3drm.c.

6697{
6698 if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6699 c1 >>= 8; c2 >>= 8;
6700 if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6701 c1 >>= 8; c2 >>= 8;
6702 if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6703 c1 >>= 8; c2 >>= 8;
6704 if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
6705 return TRUE;
6706}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

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 47 of file d3drm.c.

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

◆ create_bitmap()

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

Definition at line 5995 of file d3drm.c.

5996{
5997 unsigned int bpp = palettized ? 8 : 24;
5999 DWORD written, size, ret;
6000 unsigned char *buffer;
6001 char path[MAX_PATH];
6002 unsigned int i, j;
6004 char *filename;
6005 HANDLE file;
6006
6008 ok(ret, "Failed to get temporary file path.\n");
6010 ret = GetTempFileNameA(path, "d3d", 0, filename);
6011 ok(ret, "Failed to get filename.\n");
6013 ok(file != INVALID_HANDLE_VALUE, "Failed to open temporary file \"%s\".\n", filename);
6014
6015 size = FIELD_OFFSET(BITMAPINFO, bmiColors[palettized ? 256 : 0]);
6016
6017 memset(&file_header, 0, sizeof(file_header));
6018 file_header.bfType = 0x4d42; /* BM */
6019 file_header.bfOffBits = sizeof(file_header) + size;
6020 file_header.bfSize = file_header.bfOffBits + w * h * (bpp / 8);
6021 ret = WriteFile(file, &file_header, sizeof(file_header), &written, NULL);
6022 ok(ret && written == sizeof(file_header), "Failed to write file header.\n");
6023
6025 info->bmiHeader.biSize = sizeof(info->bmiHeader);
6026 info->bmiHeader.biBitCount = bpp;
6027 info->bmiHeader.biPlanes = 1;
6028 info->bmiHeader.biWidth = w;
6029 info->bmiHeader.biHeight = h;
6030 info->bmiHeader.biCompression = BI_RGB;
6031 if (palettized)
6032 {
6033 for (i = 0; i < 256; ++i)
6034 {
6035 info->bmiColors[i].rgbBlue = i;
6036 info->bmiColors[i].rgbGreen = i;
6037 info->bmiColors[i].rgbRed = i;
6038 }
6039 }
6040 ret = WriteFile(file, info, size, &written, NULL);
6041 ok(ret && written == size, "Failed to write bitmap info.\n");
6043
6044 size = w * h * (bpp / 8);
6046 for (i = 0, j = 0; i < size;)
6047 {
6048 if (palettized)
6049 {
6050 buffer[i++] = j++;
6051 j %= 256;
6052 }
6053 else
6054 {
6055 buffer[i++] = j % 251;
6056 buffer[i++] = j % 239;
6057 buffer[i++] = j++ % 247;
6058 }
6059 }
6060 ret = WriteFile(file, buffer, size, &written, NULL);
6061 ok(ret && written == size, "Failed to write bitmap data.\n");
6063
6065
6066 return filename;
6067}
DWORD bpp
Definition: surface.c:185
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
#define BI_RGB
Definition: precomp.h:47
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
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
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
const char * filename
Definition: ioapi.h:137
static const DWORD file_header[]
Definition: mciwnd.c:29
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:127
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int ret

◆ create_device1()

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

Definition at line 4975 of file d3drm.c.

4976{
4977 static const DWORD z_depths[] = { 32, 24, 16 };
4978 IDirectDrawSurface *surface;
4979 IDirect3DDevice *device = NULL;
4980 DDSURFACEDESC surface_desc;
4981 unsigned int i;
4982 HRESULT hr;
4983 RECT rc;
4984
4985 GetClientRect(window, &rc);
4986 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
4987 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
4988
4989 memset(&surface_desc, 0, sizeof(surface_desc));
4990 surface_desc.dwSize = sizeof(surface_desc);
4991 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4992 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
4993 surface_desc.dwWidth = rc.right;
4994 surface_desc.dwHeight = rc.bottom;
4995
4996 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
4997 ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
4998
4999 /* We used to use EnumDevices() for this, but it seems
5000 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
5001 * relationship with reality. */
5002 for (i = 0; i < ARRAY_SIZE(z_depths); ++i)
5003 {
5004 memset(&surface_desc, 0, sizeof(surface_desc));
5005 surface_desc.dwSize = sizeof(surface_desc);
5006 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
5007 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
5008 U2(surface_desc).dwZBufferBitDepth = z_depths[i];
5009 surface_desc.dwWidth = rc.right;
5010 surface_desc.dwHeight = rc.bottom;
5011 if (FAILED(IDirectDraw_CreateSurface(ddraw, &surface_desc, ds, NULL)))
5012 continue;
5013
5014 hr = IDirectDrawSurface_AddAttachedSurface(surface, *ds);
5015 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
5016 if (FAILED(hr))
5017 {
5018 IDirectDrawSurface_Release(*ds);
5019 continue;
5020 }
5021
5022 if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DHALDevice, (void **)&device)))
5023 break;
5024
5025 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, *ds);
5026 IDirectDrawSurface_Release(*ds);
5027 *ds = NULL;
5028 }
5029
5030 IDirectDrawSurface_Release(surface);
5031 return device;
5032}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define U2(x)
Definition: wordpad.c:46
#define ds
Definition: i386-dis.c:444
#define FAILED(hr)
Definition: intsafe.h:51
static IHTMLWindow2 * window
Definition: events.c:77
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:267
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define DDSD_HEIGHT
Definition: ddraw.h:209
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:213
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
#define DDSD_CAPS
Definition: ddraw.h:208
Definition: devices.h:37
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by test_create_device_from_d3d1().

◆ create_device2()

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

Definition at line 5300 of file d3drm.c.

5301{
5302 static const DWORD z_depths[] = { 32, 24, 16 };
5303 IDirectDrawSurface *surface;
5304 IDirect3DDevice2 *device = NULL;
5305 DDSURFACEDESC surface_desc;
5306 IDirect3D2 *d3d;
5307 unsigned int i;
5308 HRESULT hr;
5309 RECT rc;
5310
5311 GetClientRect(window, &rc);
5312 hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
5313 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
5314
5315 memset(&surface_desc, 0, sizeof(surface_desc));
5316 surface_desc.dwSize = sizeof(surface_desc);
5317 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
5318 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
5319 surface_desc.dwWidth = rc.right;
5320 surface_desc.dwHeight = rc.bottom;
5321
5322 hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
5323 ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
5324
5325 hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
5326 if (FAILED(hr))
5327 {
5328 IDirectDrawSurface_Release(surface);
5329 *ds = NULL;
5330 return NULL;
5331 }
5332
5333 /* We used to use EnumDevices() for this, but it seems
5334 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
5335 * relationship with reality. */
5336 for (i = 0; i < ARRAY_SIZE(z_depths); ++i)
5337 {
5338 memset(&surface_desc, 0, sizeof(surface_desc));
5339 surface_desc.dwSize = sizeof(surface_desc);
5340 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
5341 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
5342 U2(surface_desc).dwZBufferBitDepth = z_depths[i];
5343 surface_desc.dwWidth = rc.right;
5344 surface_desc.dwHeight = rc.bottom;
5345 if (FAILED(IDirectDraw2_CreateSurface(ddraw, &surface_desc, ds, NULL)))
5346 continue;
5347
5348 hr = IDirectDrawSurface_AddAttachedSurface(surface, *ds);
5349 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
5350 if (FAILED(hr))
5351 {
5352 IDirectDrawSurface_Release(*ds);
5353 continue;
5354 }
5355
5356 if (SUCCEEDED(IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device)))
5357 break;
5358
5359 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, *ds);
5360 IDirectDrawSurface_Release(*ds);
5361 *ds = NULL;
5362 }
5363
5364 IDirect3D2_Release(d3d);
5365 IDirectDrawSurface_Release(surface);
5366 return device;
5367}
#define IDirect3D2_CreateDevice(p, a, b, c)
Definition: d3d.h:287
#define IDirect3D2_Release(p)
Definition: d3d.h:280

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 6659 of file d3drm.c.

6660{
6661 IDirectDrawSurface *surface;
6662 IDirect3DDevice2 *device = NULL;
6663 DDSURFACEDESC surface_desc;
6664 IDirect3D2 *d3d;
6665 HRESULT hr;
6666 RECT rc;
6667
6668 GetClientRect(window, &rc);
6669 hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
6670 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
6671
6672 memset(&surface_desc, 0, sizeof(surface_desc));
6673 surface_desc.dwSize = sizeof(surface_desc);
6674 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
6675 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
6676 surface_desc.dwWidth = rc.right;
6677 surface_desc.dwHeight = rc.bottom;
6678
6679 hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
6680 ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
6681
6682 hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
6683 if (FAILED(hr))
6684 {
6685 IDirectDrawSurface_Release(surface);
6686 return NULL;
6687 }
6688
6689 IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device);
6690
6691 IDirect3D2_Release(d3d);
6692 IDirectDrawSurface_Release(surface);
6693 return device;
6694}

Referenced by test_viewport_clear2().

◆ create_window()

static HWND create_window ( void  )
static

Definition at line 149 of file d3drm.c.

150{
151 RECT r = {0, 0, 640, 480};
152
154
155 return CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
156 CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
157}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
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:4305
#define CW_USEDEFAULT
Definition: winuser.h:225

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 6818 of file d3drm.c.

6819{
6820 IDirect3DExecuteBuffer *execute_buffer;
6821 D3DEXECUTEBUFFERDESC exec_desc;
6822 HRESULT hr;
6823 void *ptr;
6824 UINT inst_length;
6825 D3DMATRIXHANDLE world_handle, view_handle, proj_handle;
6826 static D3DMATRIX mat =
6827 {
6828 1.0f, 0.0f, 0.0f, 0.0f,
6829 0.0f, 1.0f, 0.0f, 0.0f,
6830 0.0f, 0.0f, 1.0f, 0.0f,
6831 0.0f, 0.0f, 0.0f, 1.0f,
6832 };
6833 static const D3DLVERTEX quad_strip[] =
6834 {
6835 {{-1.0f}, {-1.0f}, {0.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6836 {{-1.0f}, { 1.0f}, {0.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6837 {{ 1.0f}, {-1.0f}, {1.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6838 {{ 1.0f}, { 1.0f}, {1.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
6839 };
6840
6841 hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
6842 ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
6843 hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat);
6844 ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
6845 hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
6846 ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
6847 hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat);
6848 ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
6849 hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
6850 ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
6851 hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat);
6852 ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
6853
6854 memset(&exec_desc, 0, sizeof(exec_desc));
6855 exec_desc.dwSize = sizeof(exec_desc);
6856 exec_desc.dwFlags = D3DDEB_BUFSIZE | D3DDEB_CAPS;
6857 exec_desc.dwBufferSize = 1024;
6858 exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
6859
6860 hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
6861 ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
6862
6863 hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
6864 ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
6865
6866 memcpy(exec_desc.lpData, quad_strip, sizeof(quad_strip));
6867 ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad_strip);
6868 emit_set_ts(&ptr, D3DTRANSFORMSTATE_WORLD, world_handle);
6869 emit_set_ts(&ptr, D3DTRANSFORMSTATE_VIEW, view_handle);
6876
6878 emit_tquad(&ptr, 0);
6879
6880 emit_end(&ptr);
6881 inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
6882 inst_length -= sizeof(quad_strip);
6883
6884 hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
6885 ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
6886
6888 set_execute_data(execute_buffer, 4, sizeof(quad_strip), inst_length);
6889 hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
6890 ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
6892 ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
6893
6894 IDirect3DExecuteBuffer_Release(execute_buffer);
6895}
@ D3DSHADE_FLAT
Definition: d3d8types.h:822
@ D3DCULL_NONE
Definition: d3d8types.h:561
#define IDirect3DDevice_Execute(p, a, b, c)
Definition: d3d.h:973
#define IDirect3DDevice_SetMatrix(p, a, b)
Definition: d3d.h:981
#define IDirect3DExecuteBuffer_Release(p)
Definition: d3d.h:904
#define IDirect3DExecuteBuffer_Lock(p, a)
Definition: d3d.h:907
#define IDirect3DExecuteBuffer_Unlock(p)
Definition: d3d.h:908
#define IDirect3DDevice_CreateExecuteBuffer(p, a, b, c)
Definition: d3d.h:971
#define IDirect3DDevice_BeginScene(p)
Definition: d3d.h:984
#define IDirect3DDevice_EndScene(p)
Definition: d3d.h:985
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice_CreateMatrix(p, a)
Definition: d3d.h:980
#define D3DDEB_CAPS
Definition: d3dcaps.h:143
#define D3DDEB_BUFSIZE
Definition: d3dcaps.h:142
#define D3DDEBCAPS_SYSTEMMEMORY
Definition: d3dcaps.h:145
#define D3DEXECUTE_CLIPPED
Definition: d3dtypes.h:1256
#define D3DPROCESSVERTICES_TRANSFORM
Definition: d3dtypes.h:1055
DWORD D3DMATRIXHANDLE
Definition: d3dtypes.h:156
#define D3DRENDERSTATE_ZENABLE
Definition: dx7todx8.h:79
#define D3DRENDERSTATE_SHADEMODE
Definition: dx7todx8.h:56
#define D3DTRANSFORMSTATE_WORLD
Definition: dx7todx8.h:22
#define D3DTRANSFORMSTATE_VIEW
Definition: dx7todx8.h:21
#define D3DTRANSFORMSTATE_PROJECTION
Definition: dx7todx8.h:12
#define D3DRENDERSTATE_FOGENABLE
Definition: dx7todx8.h:45
#define D3DRENDERSTATE_CULLMODE
Definition: dx7todx8.h:35
#define D3DRENDERSTATE_CLIPPING
Definition: dx7todx8.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
static void emit_tquad(void **ptr, WORD base_idx)
Definition: d3drm.c:6783
static void emit_set_rs(void **ptr, D3DRENDERSTATETYPE state, DWORD value)
Definition: d3drm.c:6750
static void emit_end(void **ptr)
Definition: d3drm.c:6807
static void set_execute_data(IDirect3DExecuteBuffer *execute_buffer, UINT vertex_count, UINT offset, UINT len)
Definition: d3drm.c:6721
static void emit_process_vertices(void **ptr, DWORD flags, WORD base_idx, DWORD vertex_count)
Definition: d3drm.c:6765
static void emit_set_ts(void **ptr, D3DTRANSFORMSTATETYPE state, DWORD value)
Definition: d3drm.c:6735
static const MAT2 mat
Definition: font.c:66
unsigned int UINT
Definition: ndis.h:50
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_viewport_clear1().

◆ destroy_callback()

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

Definition at line 1455 of file d3drm.c.

1456{
1457 struct destroy_context *ctxt = arg;
1458 ok(ctxt->called == 1 || ctxt->called == 2, "got called counter %d\n", ctxt->called);
1459 ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1460 d3drm_corder[ctxt->called].callback = &destroy_callback;
1461 d3drm_corder[ctxt->called++].context = ctxt;
1462}
struct callback_order d3drm_corder[3]
IDirect3DRMObject * obj
Definition: d3drm.c:1444
void * arg
Definition: msvc.h:10

◆ destroy_callback1()

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

Definition at line 1464 of file d3drm.c.

1465{
1466 struct destroy_context *ctxt = (struct destroy_context*)arg;
1467 ok(ctxt->called == 0, "got called counter %d\n", ctxt->called);
1468 ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1469 d3drm_corder[ctxt->called].callback = &destroy_callback1;
1470 d3drm_corder[ctxt->called++].context = ctxt;
1471}
static void CDECL destroy_callback1(IDirect3DRMObject *obj, void *arg)
Definition: d3drm.c:1464

Referenced by destroy_callback1(), and test_destroy_callback().

◆ draw_quad2()

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

Definition at line 7053 of file d3drm.c.

7054{
7055 static D3DLVERTEX tquad[] =
7056 {
7057 {{-1.0f}, {-1.0f}, {0.0f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
7058 {{-1.0f}, { 1.0f}, {0.0f}, 0, {0xffbada55}, {0}, {0.0f}, {1.0f}},
7059 {{ 1.0f}, {-1.0f}, {1.0f}, 0, {0xffbada55}, {0}, {1.0f}, {0.0f}},
7060 {{ 1.0f}, { 1.0f}, {1.0f}, 0, {0xffbada55}, {0}, {1.0f}, {1.0f}},
7061 };
7062 static D3DMATRIX mat =
7063 {
7064 1.0f, 0.0f, 0.0f, 0.0f,
7065 0.0f, 1.0f, 0.0f, 0.0f,
7066 0.0f, 0.0f, 1.0f, 0.0f,
7067 0.0f, 0.0f, 0.0f, 1.0f,
7068 };
7069 IDirect3DViewport2 *viewport2;
7070 HRESULT hr;
7071
7073 ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
7075 ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
7077 ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
7078
7079 hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport2, (void **)&viewport2);
7080 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport2 interface (hr = %#x).\n", hr);
7082 ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
7083 IDirect3DViewport2_Release(viewport2);
7084
7086 ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#x.\n", hr);
7088 ok(SUCCEEDED(hr), "Failed to set the z function, hr %#x.\n", hr);
7089
7091 ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
7093 ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
7095 ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
7096}
@ D3DPT_TRIANGLESTRIP
Definition: d3d8types.h:722
@ D3DCMP_LESSEQUAL
Definition: d3d8types.h:540
@ D3DZB_TRUE
Definition: d3d8types.h:980
#define IDirect3DDevice2_SetCurrentViewport(p, a)
Definition: d3d.h:1076
#define IDirect3DDevice2_BeginScene(p)
Definition: d3d.h:1073
#define IDirect3DViewport2_Release(p)
Definition: d3d.h:747
#define IDirect3DViewport_QueryInterface(p, a, b)
Definition: d3d.h:674
#define IDirect3DDevice2_SetRenderState(p, a, b)
Definition: d3d.h:1086
#define IDirect3DDevice2_DrawPrimitive(p, a, b, c, d, e)
Definition: d3d.h:1092
#define IDirect3DDevice2_EndScene(p)
Definition: d3d.h:1074
#define IDirect3DDevice2_SetTransform(p, a, b)
Definition: d3d.h:1089
@ D3DVT_LVERTEX
Definition: d3dtypes.h:815
#define D3DRENDERSTATE_ZFUNC
Definition: dx7todx8.h:80

Referenced by test_viewport_clear2().

◆ emit_end()

static void emit_end ( void **  ptr)
static

Definition at line 6807 of file d3drm.c.

6808{
6809 D3DINSTRUCTION *inst = *ptr;
6810
6811 inst->bOpcode = D3DOP_EXIT;
6812 inst->bSize = 0;
6813 inst->wCount = 0;
6814
6815 *ptr = inst + 1;
6816}
@ D3DOP_EXIT
Definition: d3dtypes.h:654

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 6765 of file d3drm.c.

6766{
6767 D3DINSTRUCTION *inst = *ptr;
6768 D3DPROCESSVERTICES *pv = (D3DPROCESSVERTICES *)(inst + 1);
6769
6771 inst->bSize = sizeof(*pv);
6772 inst->wCount = 1;
6773
6774 pv->dwFlags = flags;
6775 pv->wStart = base_idx;
6776 pv->wDest = 0;
6777 pv->dwCount = vertex_count;
6778 pv->dwReserved = 0;
6779
6780 *ptr = pv + 1;
6781}
@ D3DOP_PROCESSVERTICES
Definition: d3dtypes.h:652
GLbitfield flags
Definition: glext.h:7161
int vertex_count
Definition: d3drm.c:3367

Referenced by d3d_draw_quad1().

◆ emit_set_rs()

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

Definition at line 6750 of file d3drm.c.

6751{
6752 D3DINSTRUCTION *inst = *ptr;
6753 D3DSTATE *rs = (D3DSTATE *)(inst + 1);
6754
6755 inst->bOpcode = D3DOP_STATERENDER;
6756 inst->bSize = sizeof(*rs);
6757 inst->wCount = 1;
6758
6759 U1(*rs).drstRenderStateType = state;
6760 U2(*rs).dwArg[0] = value;
6761
6762 *ptr = rs + 1;
6763}
static int state
Definition: maze.c:121
@ D3DOP_STATERENDER
Definition: d3dtypes.h:651
#define U1(x)
Definition: test.h:199

Referenced by d3d_draw_quad1().

◆ emit_set_ts()

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

Definition at line 6735 of file d3drm.c.

6736{
6737 D3DINSTRUCTION *inst = *ptr;
6738 D3DSTATE *ts = (D3DSTATE *)(inst + 1);
6739
6741 inst->bSize = sizeof(*ts);
6742 inst->wCount = 1;
6743
6744 U1(*ts).dtstTransformStateType = state;
6745 U2(*ts).dwArg[0] = value;
6746
6747 *ptr = ts + 1;
6748}
@ D3DOP_STATETRANSFORM
Definition: d3dtypes.h:649

Referenced by d3d_draw_quad1().

◆ emit_tquad()

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

Definition at line 6783 of file d3drm.c.

6784{
6785 D3DINSTRUCTION *inst = *ptr;
6786 D3DTRIANGLE *tri = (D3DTRIANGLE *)(inst + 1);
6787
6788 inst->bOpcode = D3DOP_TRIANGLE;
6789 inst->bSize = sizeof(*tri);
6790 inst->wCount = 2;
6791
6792 U1(*tri).v1 = base_idx;
6793 U2(*tri).v2 = base_idx + 1;
6794 U3(*tri).v3 = base_idx + 2;
6795 tri->wFlags = D3DTRIFLAG_START;
6796 ++tri;
6797
6798 U1(*tri).v1 = base_idx + 2;
6799 U2(*tri).v2 = base_idx + 1;
6800 U3(*tri).v3 = base_idx + 3;
6801 tri->wFlags = D3DTRIFLAG_ODD;
6802 ++tri;
6803
6804 *ptr = tri;
6805}
#define U3(x)
Definition: wordpad.c:47
@ D3DOP_TRIANGLE
Definition: d3dtypes.h:646
#define D3DTRIFLAG_ODD
Definition: d3dtypes.h:1172
#define D3DTRIFLAG_START
Definition: d3dtypes.h:1170

Referenced by d3d_draw_quad1().

◆ expect_matrix_()

static void expect_matrix_ ( unsigned int  line,
D3DRMMATRIX4D  m,
float  m11,
float  m12,
float  m13,
float  m14,
float  m21,
float  m22,
float  m23,
float  m24,
float  m31,
float  m32,
float  m33,
float  m34,
float  m41,
float  m42,
float  m43,
float  m44,
unsigned int  ulps 
)
static

Definition at line 65 of file d3drm.c.

69{
70 BOOL equal = compare_float(m[0][0], m11, ulps) && compare_float(m[0][1], m12, ulps)
71 && compare_float(m[0][2], m13, ulps) && compare_float(m[0][3], m14, ulps)
72 && compare_float(m[1][0], m21, ulps) && compare_float(m[1][1], m22, ulps)
73 && compare_float(m[1][2], m23, ulps) && compare_float(m[1][3], m24, ulps)
74 && compare_float(m[2][0], m31, ulps) && compare_float(m[2][1], m32, ulps)
75 && compare_float(m[2][2], m33, ulps) && compare_float(m[2][3], m34, ulps)
76 && compare_float(m[3][0], m41, ulps) && compare_float(m[3][1], m42, ulps)
77 && compare_float(m[3][2], m43, ulps) && compare_float(m[3][3], m44, ulps);
78
79 ok_(__FILE__, line)(equal,
80 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
81 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
82 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
83 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
84 m[0][0], m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3],
85 m[2][0], m[2][1], m[2][2], m[2][3], m[3][0], m[3][1], m[3][2], m[3][3],
86 m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
87}
#define ok_(x1, x2)
Definition: atltest.h:61
#define m32
#define m34
#define m33
#define m14
#define m31
#define m22
#define m11
#define m43
#define m42
#define m13
#define m24
#define m23
#define m12
#define m21
#define m41
#define m44
unsigned int BOOL
Definition: ntddk_ex.h:94
const GLfloat * m
Definition: glext.h:10848
#define compare_float(got, exp)
Definition: mesh.c:52
#define equal(x, y)
Definition: reader.cc:56
Definition: parser.c:49

◆ expect_vector_()

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

Definition at line 90 of file d3drm.c.

91{
92 BOOL equal = compare_float(U1(*v).x, x, ulps)
93 && compare_float(U2(*v).y, y, ulps)
94 && compare_float(U3(*v).z, z, ulps);
95
96 ok_(__FILE__, line)(equal, "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
97 U1(*v).x, U2(*v).y, U3(*v).z, x, y, z);
98}
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by vector_eq_().

◆ frame_set_transform()

static void frame_set_transform ( IDirect3DRMFrame *  frame,
float  m11,
float  m12,
float  m13,
float  m14,
float  m21,
float  m22,
float  m23,
float  m24,
float  m31,
float  m32,
float  m33,
float  m34,
float  m41,
float  m42,
float  m43,
float  m44 
)
static

Definition at line 113 of file d3drm.c.

116{
118 {
119 {m11, m12, m13, m14},
120 {m21, m22, m23, m24},
121 {m31, m32, m33, m34},
122 {m41, m42, m43, m44},
123 };
124
126}
@ D3DRMCOMBINE_REPLACE
Definition: d3drmdef.h:125
D3DVALUE D3DRMMATRIX4D[4][4]
Definition: d3drmdef.h:39
#define IDirect3DRMFrame_AddTransform(p, a, b)
Definition: d3drmobj.h:1182
GLuint GLenum matrix
Definition: glext.h:9407

Referenced by test_frame_transform().

◆ get_refcount()

◆ get_surface_color()

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

Definition at line 6636 of file d3drm.c.

6637{
6638 RECT rect = { x, y, x + 1, y + 1 };
6639 DDSURFACEDESC surface_desc;
6641 HRESULT hr;
6642
6643 memset(&surface_desc, 0, sizeof(surface_desc));
6644 surface_desc.dwSize = sizeof(surface_desc);
6645
6646 hr = IDirectDrawSurface_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
6647 ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
6648 if (FAILED(hr))
6649 return 0xdeadbeef;
6650
6651 color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
6652
6653 hr = IDirectDrawSurface_Unlock(surface, NULL);
6654 ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
6655
6656 return color;
6657}
GLuint color
Definition: glext.h:6243
DWORD color
Definition: d3drm.c:3371
#define DDLOCK_READONLY
Definition: ddraw.h:624
#define DDLOCK_WAIT
Definition: ddraw.h:622
& rect
Definition: startmenu.cpp:1413

Referenced by test_viewport_clear1(), and test_viewport_clear2().

◆ matrix_sanitise()

static void matrix_sanitise ( D3DRMMATRIX4D  m)
static

Definition at line 135 of file d3drm.c.

136{
137 unsigned int i, j;
138
139 for (i = 0; i < 4; ++i)
140 {
141 for (j = 0; j < 4; ++j)
142 {
143 if (m[i][j] > -1e-7f && m[i][j] < 1e-7f)
144 m[i][j] = 0.0f;
145 }
146 }
147}

Referenced by test_frame_transform().

◆ object_load_callback()

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

Definition at line 3302 of file d3drm.c.

3303{
3304 ok(object != NULL, "Arg 1 should not be null\n");
3305 ok(IsEqualGUID(objectguid, refiids[nb_objects]), "Arg 2 is incorrect\n");
3306 ok(arg == (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg);
3307 nb_objects++;
3308}
static int nb_objects
Definition: d3drm.c:3293
static const GUID * refiids[]
Definition: d3drm.c:3294
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

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 3332 of file d3drm.c.

3333{
3334 HRESULT hr;
3335 IDirect3DRMFrame *frame;
3336 IDirect3DRMVisualArray *array;
3337 IDirect3DRMVisual *visual;
3338 ULONG size;
3339 char name[128];
3340
3341 hr = IDirect3DRMObject_QueryInterface(object, &IID_IDirect3DRMFrame, (void**)&frame);
3342 ok(hr == D3DRM_OK, "IDirect3DRMObject_QueryInterface returned %x\n", hr);
3343
3345 ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetVisuals returned %x\n", hr);
3346
3348 ok(size == 1, "Wrong size %u returned, expected 1\n", size);
3349
3351 ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetElement returned %x\n", hr);
3352
3353 hr = IDirect3DRMVisual_QueryInterface(visual, &IID_IDirect3DRMMeshBuilder, (void**)&mesh_builder);
3354 ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetSize returned %x\n", hr);
3355
3356 size = sizeof(name);
3358 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr);
3359 ok(!strcmp(name, "mesh1"), "Wrong name %s, expected mesh1\n", name);
3360
3364}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define D3DRM_OK
Definition: d3drm.h:486
#define IDirect3DRMFrame_GetVisuals(p, a)
Definition: d3drmobj.h:1200
#define IDirect3DRMVisualArray_Release(p)
Definition: d3drmobj.h:4346
#define IDirect3DRMObject_QueryInterface(p, a, b)
Definition: d3drmobj.h:218
#define IDirect3DRMFrame_Release(p)
Definition: d3drmobj.h:1168
#define IDirect3DRMVisualArray_GetSize(p)
Definition: d3drmobj.h:4348
#define IDirect3DRMVisual_Release(p)
Definition: d3drmobj.h:330
#define IDirect3DRMVisualArray_GetElement(p, a, b)
Definition: d3drmobj.h:4350
#define IDirect3DRMMeshBuilder_GetName(p, a, b)
Definition: d3drmobj.h:2560
#define IDirect3DRMVisual_QueryInterface(p, a, b)
Definition: d3drmobj.h:328
IDirect3DRMMeshBuilder * mesh_builder
Definition: d3drm.c:3330
Definition: name.c:39
uint32_t ULONG
Definition: typedefs.h:59

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 6721 of file d3drm.c.

6722{
6723 D3DEXECUTEDATA exec_data;
6724 HRESULT hr;
6725
6726 memset(&exec_data, 0, sizeof(exec_data));
6727 exec_data.dwSize = sizeof(exec_data);
6728 exec_data.dwVertexCount = vertex_count;
6729 exec_data.dwInstructionOffset = offset;
6730 exec_data.dwInstructionLength = len;
6731 hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
6732 ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
6733}
#define IDirect3DExecuteBuffer_SetExecuteData(p, a)
Definition: d3d.h:909
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
DWORD dwInstructionOffset
Definition: d3dtypes.h:1263
DWORD dwVertexCount
Definition: d3dtypes.h:1262
DWORD dwInstructionLength
Definition: d3dtypes.h:1264

Referenced by d3d_draw_quad1().

◆ set_vector()

static void set_vector ( D3DVECTOR v,
float  x,
float  y,
float  z 
)
static

Definition at line 128 of file d3drm.c.

129{
130 U1(*v).x = x;
131 U2(*v).y = y;
132 U3(*v).z = z;
133}

Referenced by test_frame_transform().

◆ START_TEST()

START_TEST ( d3drm  )

Definition at line 8033 of file d3drm.c.

8034{
8037 test_Mesh();
8038 test_Face();
8039 test_Frame();
8040 test_Device();
8041 test_object();
8042 test_Viewport();
8043 test_Light();
8045 test_Texture();
8049 test_d3drm_qi();
8050 test_frame_qi();
8072 test_wrap();
8073 test_wrap_qi();
8074}
static void test_create_device_from_clipper1(void)
Definition: d3drm.c:3859
static void test_texture_qi(void)
Definition: d3drm.c:6365
static void test_animation_qi(void)
Definition: d3drm.c:7822
static void test_Mesh(void)
Definition: d3drm.c:805
static void test_Material2(void)
Definition: d3drm.c:2566
static void test_Texture(void)
Definition: d3drm.c:2634
static void test_d3drm_qi(void)
Definition: d3drm.c:3512
static void test_create_device_2(void)
Definition: d3drm.c:5951
static void test_load_texture(void)
Definition: d3drm.c:6185
static void test_MeshBuilder3(void)
Definition: d3drm.c:706
static void test_wrap_qi(void)
Definition: d3drm.c:7945
static void test_create_device_3(void)
Definition: d3drm.c:5973
static void test_create_device_from_d3d3(void)
Definition: d3drm.c:5652
static void test_create_device_from_surface3(void)
Definition: d3drm.c:4738
static void test_animation(void)
Definition: d3drm.c:7479
static void test_MeshBuilder(void)
Definition: d3drm.c:422
static void test_create_device_from_clipper2(void)
Definition: d3drm.c:4029
static void test_Device(void)
Definition: d3drm.c:2982
static void test_create_device_from_d3d2(void)
Definition: d3drm.c:5369
static void test_viewport_clear2(void)
Definition: d3drm.c:7098
static void test_device_qi(void)
Definition: d3drm.c:3713
static void test_frame_transform(void)
Definition: d3drm.c:3031
static void test_viewport_qi(void)
Definition: d3drm.c:6490
static void test_Light(void)
Definition: d3drm.c:2518
static void test_create_device_1(void)
Definition: d3drm.c:5933
static void test_frame_qi(void)
Definition: d3drm.c:3596
static void test_create_device_from_surface1(void)
Definition: d3drm.c:4385
static void test_create_device_from_surface2(void)
Definition: d3drm.c:4556
static void test_Viewport(void)
Definition: d3drm.c:1713
static void test_object(void)
Definition: d3drm.c:1575
static void test_frame_mesh_materials(void)
Definition: d3drm.c:3381
static void test_create_device_from_d3d1(void)
Definition: d3drm.c:5034
static void test_create_texture_from_surface(void)
Definition: d3drm.c:7313
static void test_d3drm_load(void)
Definition: d3drm.c:3310
static void test_viewport_clear1(void)
Definition: d3drm.c:6897
static void test_create_device_from_clipper3(void)
Definition: d3drm.c:4207
static void test_Face(void)
Definition: d3drm.c:834
static void test_wrap(void)
Definition: d3drm.c:7927
static void test_Frame(void)
Definition: d3drm.c:1049

◆ surface_callback()

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

Definition at line 3845 of file d3drm.c.

3846{
3847 IDirectDrawSurface **primary = context;
3848
3849 if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
3850 {
3851 *primary = surface;
3852 return DDENUMRET_CANCEL;
3853 }
3854 IDirectDrawSurface_Release(surface);
3855
3856 return DDENUMRET_OK;
3857}
static const WCHAR desc[]
Definition: protectdata.c:36
#define DDENUMRET_OK
Definition: ddraw.h:189
#define DDSCAPS_PRIMARYSURFACE
Definition: ddraw.h:258
#define DDENUMRET_CANCEL
Definition: ddraw.h:188
Definition: http.c:7252

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 7479 of file d3drm.c.

7480{
7481 IDirect3DRMAnimation2 *animation2;
7482 IDirect3DRMAnimation *animation;
7484 IDirect3DRMObject *obj, *obj2;
7485 D3DRMANIMATIONKEY keys[10];
7486 IDirect3DRMFrame3 *frame3;
7487 IDirect3DRMFrame *frame;
7489 IDirect3DRM *d3drm1;
7491 DWORD count, i;
7492 HRESULT hr;
7493 D3DVECTOR v;
7494
7495 hr = Direct3DRMCreate(&d3drm1);
7496 ok(SUCCEEDED(hr), "Failed to create IDirect3DRM instance, hr 0x%08x.\n", hr);
7497
7499 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr 0x%08x.\n", hr);
7500
7501 CHECK_REFCOUNT(d3drm1, 1);
7502 hr = IDirect3DRM_CreateAnimation(d3drm1, &animation);
7503 ok(SUCCEEDED(hr), "Failed to create animation hr 0x%08x.\n", hr);
7504 CHECK_REFCOUNT(d3drm1, 2);
7505
7506 test_class_name((IDirect3DRMObject *)animation, "Animation");
7507
7508 hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IDirect3DRMAnimation2, (void **)&animation2);
7509 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMAnimation2, hr 0x%08x.\n", hr);
7510 ok(animation != (void *)animation2, "Expected different interface pointer.\n");
7511
7512 hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IDirect3DRMObject, (void **)&obj);
7513 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr 0x%08x.\n", hr);
7514
7515 hr = IDirect3DRMAnimation2_QueryInterface(animation2, &IID_IDirect3DRMObject, (void **)&obj2);
7516 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr 0x%08x.\n", hr);
7517
7518 ok(obj == obj2 && obj == (IDirect3DRMObject *)animation, "Unexpected object pointer.\n");
7519
7522
7523 /* Set animated frame, get it back. */
7524 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame);
7525 ok(SUCCEEDED(hr), "Failed to create a frame, hr %#x.\n", hr);
7526
7528 ok(SUCCEEDED(hr), "Failed to reset frame, hr %#x.\n", hr);
7529
7530 CHECK_REFCOUNT(frame, 1);
7531 hr = IDirect3DRMAnimation_SetFrame(animation, frame);
7532 ok(SUCCEEDED(hr), "Failed to set a frame, hr %#x.\n", hr);
7533 CHECK_REFCOUNT(frame, 1);
7534
7535 hr = IDirect3DRMAnimation2_GetFrame(animation2, NULL);
7536 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7537
7538 hr = IDirect3DRMAnimation2_GetFrame(animation2, &frame3);
7539 ok(SUCCEEDED(hr), "Failed to get the frame, %#x.\n", hr);
7540 ok(frame3 != (void *)frame, "Unexpected interface pointer.\n");
7541 CHECK_REFCOUNT(frame, 2);
7542
7544
7546 ok(SUCCEEDED(hr), "Failed to reset frame, hr %#x.\n", hr);
7547
7548 hr = IDirect3DRMFrame_QueryInterface(frame, &IID_IDirect3DRMFrame3, (void **)&frame3);
7549 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMFrame3, hr %#x.\n", hr);
7550
7551 CHECK_REFCOUNT(frame3, 2);
7552 hr = IDirect3DRMAnimation2_SetFrame(animation2, frame3);
7553 ok(SUCCEEDED(hr), "Failed to set a frame, hr %#x.\n", hr);
7554 CHECK_REFCOUNT(frame3, 2);
7555
7558
7559 /* Animation options. */
7562 "Unexpected default options %#x.\n", options);
7563
7564 /* Undefined mask value */
7565 hr = IDirect3DRMAnimation_SetOptions(animation, 0xf0000000);
7566 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7567
7570 "Unexpected default options %#x.\n", options);
7571
7572 /* Ambiguous mask */
7574 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7575
7577 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7578
7580 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7581
7584 "Unexpected default options %#x.\n", options);
7585
7586 /* Mask contains undefined bits together with valid one. */
7587 hr = IDirect3DRMAnimation_SetOptions(animation, 0xf0000000 | D3DRMANIMATION_OPEN);
7588 ok(SUCCEEDED(hr), "Failed to set animation options, hr %#x.\n", hr);
7589
7591 ok(options == (0xf0000000 | D3DRMANIMATION_OPEN), "Unexpected animation options %#x.\n", options);
7592
7594 ok(SUCCEEDED(hr), "Failed to set animation options, hr %#x.\n", hr);
7595
7597 ok(options == D3DRMANIMATION_SCALEANDROTATION, "Unexpected options %#x.\n", options);
7598
7600 ok(SUCCEEDED(hr), "Failed to set animation options, hr %#x.\n", hr);
7601
7603 ok(options == D3DRMANIMATION_OPEN, "Unexpected options %#x.\n", options);
7604
7605 hr = IDirect3DRMAnimation_SetOptions(animation, 0);
7606 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7607
7609 ok(options == D3DRMANIMATION_OPEN, "Unexpected options %#x.\n", options);
7610
7611 /* Key management. */
7612 hr = IDirect3DRMAnimation_AddPositionKey(animation, 0.0f, 1.0f, 0.0f, 0.0f);
7613 ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
7614
7615 hr = IDirect3DRMAnimation_AddScaleKey(animation, 0.0f, 1.0f, 2.0f, 1.0f);
7616 ok(SUCCEEDED(hr), "Failed to add scale key, hr %#x.\n", hr);
7617
7618 hr = IDirect3DRMAnimation_AddPositionKey(animation, 0.0f, 2.0f, 0.0f, 0.0f);
7619 ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
7620
7621 hr = IDirect3DRMAnimation_AddPositionKey(animation, 99.0f, 3.0f, 1.0f, 0.0f);
7622 ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
7623
7624 hr = IDirect3DRMAnimation_AddPositionKey(animation, 80.0f, 4.0f, 1.0f, 0.0f);
7625 ok(SUCCEEDED(hr), "Failed to add position key, hr %#x.\n", hr);
7626
7627 v.x = 1.0f;
7628 v.y = 0.0f;
7629 v.z = 0.0f;
7631
7632 /* NULL quaternion pointer leads to a crash on Windows. */
7633 hr = IDirect3DRMAnimation_AddRotateKey(animation, 0.0f, &q);
7634 ok(SUCCEEDED(hr), "Failed to add rotation key, hr %#.x\n", hr);
7635
7636 count = 0;
7637 memset(keys, 0, sizeof(keys));
7638 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 99.0f, &count, keys);
7639 ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#x.\n", hr);
7640 ok(count == 6, "Unexpected key count %u.\n", count);
7641
7642 ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[0].dwKeyType);
7643 ok(keys[1].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[1].dwKeyType);
7644 ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[2].dwKeyType);
7645 ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[3].dwKeyType);
7646 ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[4].dwKeyType);
7647 ok(keys[5].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[5].dwKeyType);
7648
7649 /* Relative order, keys are returned sorted by time. */
7650 ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7651 ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7652 ok(keys[3].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7653 ok(keys[4].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7654
7655 /* For keys with same time, order they were added in is kept. */
7656 ok(keys[1].dvPositionKey.x == 1.0f, "Unexpected key position x %.8e.\n", keys[1].dvPositionKey.x);
7657 ok(keys[2].dvPositionKey.x == 2.0f, "Unexpected key position x %.8e.\n", keys[2].dvPositionKey.x);
7658 ok(keys[3].dvPositionKey.x == 4.0f, "Unexpected key position x %.8e.\n", keys[3].dvPositionKey.x);
7659 ok(keys[4].dvPositionKey.x == 3.0f, "Unexpected key position x %.8e.\n", keys[4].dvPositionKey.x);
7660
7661 for (i = 0; i < count; i++)
7662 {
7663 ok(keys[i].dwSize == sizeof(*keys), "%u: unexpected dwSize value %u.\n", i, keys[i].dwSize);
7664
7665 todo_wine
7666 {
7667 switch (keys[i].dwKeyType)
7668 {
7670 ok((keys[i].dwID & 0xf0000000) == 0x40000000, "%u: unexpected id mask %#x.\n", i, keys[i].dwID);
7671 break;
7673 ok((keys[i].dwID & 0xf0000000) == 0x80000000, "%u: unexpected id mask %#x.\n", i, keys[i].dwID);
7674 break;
7676 ok((keys[i].dwID & 0xf0000000) == 0xc0000000, "%u: unexpected id mask %#x.\n", i, keys[i].dwID);
7677 break;
7678 default:
7679 ok(0, "%u: unknown key type %d.\n", i, keys[i].dwKeyType);
7680 }
7681 }
7682 }
7683
7684 /* No keys in this range. */
7685 count = 10;
7686 hr = IDirect3DRMAnimation2_GetKeys(animation2, 100.0f, 200.0f, &count, NULL);
7687 ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#x.\n", hr);
7688 ok(count == 0, "Unexpected key count %u.\n", count);
7689
7690 count = 10;
7691 hr = IDirect3DRMAnimation2_GetKeys(animation2, 100.0f, 200.0f, &count, keys);
7692 ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#x.\n", hr);
7693 ok(count == 0, "Unexpected key count %u.\n", count);
7694
7695 count = 10;
7696 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 0.0f, &count, NULL);
7697 ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#x.\n", hr);
7698 ok(count == 4, "Unexpected key count %u.\n", count);
7699
7700 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, NULL, NULL);
7701 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7702
7703 /* Time is 0-based. */
7704 hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, -50.0f, NULL, NULL);
7705 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
7706
7707 count = 10;
7708 hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, -50.0f, &count, NULL);
7709 ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#x.\n", hr);
7710 ok(count == 0, "Unexpected key count %u.\n", count);
7711
7712 count = 10;
7713 hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, 100.0f, &count, NULL);
7714 ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#x.\n", hr);
7715 ok(count == 6, "Unexpected key count %u.\n", count);
7716
7717 /* AddKey() tests. */
7718 hr = IDirect3DRMAnimation2_AddKey(animation2, NULL);
7719 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7720
7721 memset(&key, 0, sizeof(key));
7722 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7723 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7724 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7725
7726 memset(&key, 0, sizeof(key));
7727 key.dwSize = sizeof(key) - 1;
7728 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7729 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7730 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7731
7732 memset(&key, 0, sizeof(key));
7733 key.dwSize = sizeof(key) + 1;
7734 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7735 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7736 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
7737
7738 memset(&key, 0, sizeof(key));
7739 key.dwSize = sizeof(key);
7740 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7741 key.dvPositionKey.x = 8.0f;
7742 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7743 ok(SUCCEEDED(hr), "Failed to add key, hr %#x.\n", hr);
7744
7745 /* Delete tests. */
7746 hr = IDirect3DRMAnimation_AddRotateKey(animation, 0.0f, &q);
7747 ok(SUCCEEDED(hr), "Failed to add rotation key, hr %#.x\n", hr);
7748
7749 hr = IDirect3DRMAnimation_AddScaleKey(animation, 0.0f, 1.0f, 2.0f, 1.0f);
7750 ok(SUCCEEDED(hr), "Failed to add scale key, hr %#x.\n", hr);
7751
7752 count = 0;
7753 memset(keys, 0, sizeof(keys));
7754 hr = IDirect3DRMAnimation2_GetKeys(animation2, -1000.0f, 1000.0f, &count, keys);
7755 ok(SUCCEEDED(hr), "Failed to get key count, hr %#x.\n", hr);
7756 ok(count == 9, "Unexpected key count %u.\n", count);
7757
7758 ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[0].dwKeyType);
7759 ok(keys[1].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[1].dwKeyType);
7760 ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[2].dwKeyType);
7761 ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[3].dwKeyType);
7762 ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[4].dwKeyType);
7763 ok(keys[5].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[5].dwKeyType);
7764 ok(keys[6].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[6].dwKeyType);
7765 ok(keys[7].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[7].dwKeyType);
7766 ok(keys[8].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[8].dwKeyType);
7767
7768 ok(keys[0].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[0].dvTime);
7769 ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7770 ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7771 ok(keys[3].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7772 ok(keys[4].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7773 ok(keys[5].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[5].dvTime);
7774 ok(keys[6].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[6].dvTime);
7775 ok(keys[7].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[7].dvTime);
7776 ok(keys[8].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[8].dvTime);
7777
7778 hr = IDirect3DRMAnimation_DeleteKey(animation, -100.0f);
7779 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7780
7781 hr = IDirect3DRMAnimation_DeleteKey(animation, 100.0f);
7782 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7783
7784 /* Only first Position keys are not removed. */
7785 hr = IDirect3DRMAnimation_DeleteKey(animation, 0.0f);
7786 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7787
7788 count = 0;
7789 memset(keys, 0, sizeof(keys));
7790 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, &count, keys);
7791 ok(SUCCEEDED(hr), "Failed to get key count, hr %#x.\n", hr);
7792 ok(count == 6, "Unexpected key count %u.\n", count);
7793
7794 ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %u.\n", keys[0].dwKeyType);
7795 ok(keys[1].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[1].dwKeyType);
7796 ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[2].dwKeyType);
7797 ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[3].dwKeyType);
7798 ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %u.\n", keys[4].dwKeyType);
7799 ok(keys[5].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %u.\n", keys[5].dwKeyType);
7800
7801 ok(keys[0].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[0].dvTime);
7802 ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7803 ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7804 ok(keys[3].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7805 ok(keys[4].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7806 ok(keys[5].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[5].dvTime);
7807
7808 hr = IDirect3DRMAnimation_DeleteKey(animation, 0.0f);
7809 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#x.\n", hr);
7810
7811 count = 0;
7812 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, &count, NULL);
7813 ok(SUCCEEDED(hr), "Failed to get key count, hr %#x.\n", hr);
7814 ok(count == 3, "Unexpected key count %u.\n", count);
7815
7818
7819 IDirect3DRM_Release(d3drm1);
7820}
#define D3DRMERR_NOSUCHKEY
Definition: d3drm.h:514
#define IDirect3DRM_CreateAnimation(p, a)
Definition: d3drm.h:118
#define IDirect3DRM_CreateFrame(p, a, b)
Definition: d3drm.h:114
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
DWORD D3DRMANIMATIONOPTIONS
Definition: d3drmdef.h:322
#define D3DRMANIMATION_LINEARPOSITION
Definition: d3drmdef.h:325
#define D3DRMANIMATION_POSITION
Definition: d3drmdef.h:328
#define D3DRMANIMATION_SCALEKEY
Definition: d3drmdef.h:415
#define D3DRMANIMATION_SCALEANDROTATION
Definition: d3drmdef.h:327
#define D3DRMANIMATION_POSITIONKEY
Definition: d3drmdef.h:416
#define D3DRMANIMATION_CLOSED
Definition: d3drmdef.h:324
#define D3DRMANIMATION_ROTATEKEY
Definition: d3drmdef.h:414
#define D3DRMANIMATION_SPLINEPOSITION
Definition: d3drmdef.h:326
#define D3DRMANIMATION_OPEN
Definition: d3drmdef.h:323
#define IDirect3DRMAnimation_GetOptions(p)
Definition: d3drmobj.h:3829
#define IDirect3DRMAnimation_QueryInterface(p, a, b)
Definition: d3drmobj.h:3809
#define IDirect3DRMAnimation_AddRotateKey(p, a, b)
Definition: d3drmobj.h:3823
#define IDirect3DRMAnimation2_GetFrame(p, a)
Definition: d3drmobj.h:3914
#define IDirect3DRMAnimation_SetFrame(p, a)
Definition: d3drmobj.h:3827
#define IDirect3DRMAnimation2_GetKeys(p, a, b, c, d)
Definition: d3drmobj.h:3918
#define IDirect3DRMAnimation_SetOptions(p, a)
Definition: d3drmobj.h:3822
#define IDirect3DRMAnimation_AddScaleKey(p, a, b, c, d)
Definition: d3drmobj.h:3825
#define IDirect3DRMAnimation_AddPositionKey(p, a, b, c, d)
Definition: d3drmobj.h:3824
#define IDirect3DRMFrame_QueryInterface(p, a, b)
Definition: d3drmobj.h:1166
#define IDirect3DRMFrame3_Release(p)
Definition: d3drmobj.h:1708
#define IDirect3DRMAnimation_DeleteKey(p, a)
Definition: d3drmobj.h:3826
#define IDirect3DRMAnimation2_SetFrame(p, a)
Definition: d3drmobj.h:3911
#define IDirect3DRMAnimation2_AddKey(p, a)
Definition: d3drmobj.h:3916
#define IDirect3DRMAnimation2_Release(p)
Definition: d3drmobj.h:3895
#define IDirect3DRMAnimation2_QueryInterface(p, a, b)
Definition: d3drmobj.h:3893
#define IDirect3DRMAnimation_Release(p)
Definition: d3drmobj.h:3811
#define IDirect3DRMObject_Release(p)
Definition: d3drmobj.h:220
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
Definition: d3drm.c:2322
D3DRMQUATERNION *WINAPI D3DRMQuaternionFromRotation(D3DRMQUATERNION *q, D3DVECTOR *v, D3DVALUE theta)
Definition: math.c:104
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define CHECK_REFCOUNT(obj, rc)
Definition: d3drm.c:34
#define test_class_name(a, b)
Definition: d3drm.c:159
#define todo_wine
Definition: custom.c:79
Definition: copy.c:22

Referenced by START_TEST().

◆ test_animation_qi()

static void test_animation_qi ( void  )
static

Definition at line 7822 of file d3drm.c.

7823{
7824 static const struct qi_test tests[] =
7825 {
7826 { &IID_IDirect3DRMAnimation2, &IID_IUnknown, &IID_IDirect3DRMAnimation2, S_OK },
7827 { &IID_IDirect3DRMAnimation, &IID_IUnknown, &IID_IDirect3DRMAnimation, S_OK },
7828 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7829 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7830 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMAnimation, S_OK },
7831 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7832 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7833 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7834 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7835 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7836 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7837 { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7838 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7839 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7840 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7841 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7842 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7843 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7844 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7845 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7846 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7847 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7848 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7849 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7850 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7851 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7852 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7853 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7854 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7855 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7856 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7857 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7858 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7859 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7860 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7861 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7862 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7863 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7864 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7865 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7866 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7867 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7868 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7869 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7870 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7871 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7872 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7873 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7874 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7875 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7876 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7877 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7878 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7879 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7880 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7881 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7882 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7883 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7884 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7885 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7886 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7887 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
7889 };
7890 IDirect3DRMAnimation2 *animation2;
7891 IDirect3DRMAnimation *animation;
7892 IDirect3DRM3 *d3drm3;
7893 IDirect3DRM *d3drm1;
7895 HRESULT hr;
7896
7897 hr = Direct3DRMCreate(&d3drm1);
7898 ok(SUCCEEDED(hr), "Failed to create d3drm instance, hr %#x.\n", hr);
7899
7900 hr = IDirect3DRM_CreateAnimation(d3drm1, &animation);
7901 ok(SUCCEEDED(hr), "Failed to create animation hr %#x.\n", hr);
7902
7904 ok(SUCCEEDED(hr), "Failed to get IUnknown from animation, hr %#x.\n", hr);
7906
7907 test_qi("animation_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
7908 IUnknown_Release(unknown);
7909
7910 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
7911 ok(SUCCEEDED(hr), "Failed to get IDirect3DRM3, hr %#x.\n", hr);
7912
7913 hr = IDirect3DRM3_CreateAnimation(d3drm3, &animation2);
7914 ok(SUCCEEDED(hr), "Failed to create animation hr %#x.\n", hr);
7915
7917 ok(SUCCEEDED(hr), "Failed to get IUnknown from animation, hr %#x.\n", hr);
7919
7920 test_qi("animation2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
7921 IUnknown_Release(unknown);
7922
7923 IDirect3DRM3_Release(d3drm3);
7924 IDirect3DRM_Release(d3drm1);
7925}
const GUID IID_IUnknown
#define IDirect3DRM_QueryInterface(p, a, b)
Definition: d3drm.h:109
#define IDirect3DRM3_CreateAnimation(p, a)
Definition: d3drm.h:407
#define IDirect3DRM3_Release(p)
Definition: d3drm.h:400
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define S_OK
Definition: intsafe.h:52
static struct test_info tests[]
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:3463
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663

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 6069 of file d3drm.c.

6071{
6072 const unsigned char *data = img->buffer1;
6073 unsigned int i, j;
6074
6075 ok(img->width == w, "Test %u: Got unexpected image width %u, expected %u.\n", test_idx, img->width, w);
6076 ok(img->height == h, "Test %u: Got unexpected image height %u, expected %u.\n", test_idx, img->height, h);
6077 ok(img->aspectx == 1, "Test %u: Got unexpected image aspectx %u.\n", test_idx, img->aspectx);
6078 ok(img->aspecty == 1, "Test %u: Got unexpected image aspecty %u.\n", test_idx, img->aspecty);
6079 ok(!img->buffer2, "Test %u: Got unexpected image buffer2 %p.\n", test_idx, img->buffer2);
6080
6081 /* The image is palettized if the total number of colors used is <= 256. */
6082 if (w * h > 256 && !palettized)
6083 {
6084 /* D3drm aligns the 24bpp texture to 4 bytes in the buffer, with one
6085 * byte padding from 24bpp texture. */
6086 ok(img->depth == 32, "Test %u: Got unexpected image depth %u.\n", test_idx, img->depth);
6087 ok(img->rgb == TRUE, "Test %u: Got unexpected image rgb %#x.\n", test_idx, img->rgb);
6088 ok(img->bytes_per_line == w * 4, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6089 test_idx, img->bytes_per_line, w * 4);
6090 ok(img->red_mask == 0xff0000, "Test %u: Got unexpected image red mask %#x.\n", test_idx, img->red_mask);
6091 ok(img->green_mask == 0x00ff00, "Test %u: Got unexpected image green mask %#x.\n", test_idx, img->green_mask);
6092 ok(img->blue_mask == 0x0000ff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx, img->blue_mask);
6093 ok(!img->alpha_mask, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx, img->alpha_mask);
6094 ok(!img->palette_size, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
6095 ok(!img->palette, "Test %u: Got unexpected image palette %p.\n", test_idx, img->palette);
6096 for (i = 0; i < h; ++i)
6097 {
6098 for (j = 0; j < w; ++j)
6099 {
6100 const unsigned char *ptr = &data[i * img->bytes_per_line + j * 4];
6101 unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
6102
6103 if (ptr[0] != idx % 251 || ptr[1] != idx % 239 || ptr[2] != idx % 247 || ptr[3] != 0xff)
6104 {
6105 ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
6106 "expected 0x%02x%02x%02x%02x.\n", test_idx, ptr[0], ptr[1], ptr[2], ptr[3],
6107 j, i, idx % 251, idx % 239, idx % 247, 0xff);
6108 return;
6109 }
6110 }
6111 }
6112 return;
6113 }
6114
6115 ok(img->depth == 8, "Test %u: Got unexpected image depth %u.\n", test_idx, img->depth);
6116 ok(!img->rgb, "Test %u: Got unexpected image rgb %#x.\n", test_idx, img->rgb);
6117 ok(img->red_mask == 0xff, "Test %u: Got unexpected image red mask %#x.\n", test_idx, img->red_mask);
6118 ok(img->green_mask == 0xff, "Test %u: Got unexpected image green mask %#x.\n", test_idx, img->green_mask);
6119 ok(img->blue_mask == 0xff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx, img->blue_mask);
6120 ok(!img->alpha_mask, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx, img->alpha_mask);
6121 ok(!!img->palette, "Test %u: Got unexpected image palette %p.\n", test_idx, img->palette);
6122 if (!palettized)
6123 {
6124 /* In this case, bytes_per_line is aligned to the next multiple of
6125 * 4 from width. */
6126 ok(img->bytes_per_line == ((w + 3) & ~3), "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6127 test_idx, img->bytes_per_line, (w + 3) & ~3);
6128 ok(img->palette_size == w * h, "Test %u: Got unexpected palette size %u, expected %u.\n",
6129 test_idx, img->palette_size, w * h);
6130 for (i = 0; i < img->palette_size; ++i)
6131 {
6132 unsigned int idx = upside_down ? (h - 1) * w - i + (i % w) * 2 : i;
6133 ok(img->palette[i].red == idx % 251
6134 && img->palette[i].green == idx % 239 && img->palette[i].blue == idx % 247,
6135 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
6136 test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
6137 ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
6138 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
6139 test_idx, i, img->palette[i].flags);
6140 }
6141 for (i = 0; i < h; ++i)
6142 {
6143 for (j = 0; j < w; ++j)
6144 {
6145 if (data[i * img->bytes_per_line + j] != i * w + j)
6146 {
6147 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
6148 test_idx, data[i * img->bytes_per_line + j], j, i, i * w + j);
6149 return;
6150 }
6151 }
6152 }
6153 return;
6154 }
6155
6156 /* bytes_per_line is not always aligned by d3drm depending on the
6157 * format. */
6158 ok(img->bytes_per_line == w, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6159 test_idx, img->bytes_per_line, w);
6160 ok(img->palette_size == 256, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
6161 for (i = 0; i < 256; ++i)
6162 {
6163 ok(img->palette[i].red == i && img->palette[i].green == i && img->palette[i].blue == i,
6164 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
6165 test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
6166 ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
6167 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
6168 test_idx, i, img->palette[i].flags);
6169 }
6170 for (i = 0; i < h; ++i)
6171 {
6172 for (j = 0; j < w; ++j)
6173 {
6174 unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
6175 if (data[i * img->bytes_per_line + j] != idx % 256)
6176 {
6177 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
6178 test_idx, data[i * img->bytes_per_line + j], j, i, idx % 256);
6179 return;
6180 }
6181 }
6182 }
6183}
@ D3DRMPALETTE_READONLY
Definition: d3drmdef.h:135
unsigned int idx
Definition: utils.c:41
GLint GLvoid * img
Definition: gl.h:1956
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

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 160 of file d3drm.c.

161{
162 char cname[64] = {0};
163 DWORD size, size2;
164 HRESULT hr;
165
166 hr = IDirect3DRMObject_GetClassName(object, NULL, cname);
167 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
169 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
170
171 size = 0;
173 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname size, hr %#x.\n", hr);
174 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
175
176 size = size2 = !!*name;
177 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
178 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
179 ok_(__FILE__, line)(size == size2, "Got size %u.\n", size);
180
181 size = sizeof(cname);
182 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
183 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#x.\n", hr);
184 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
185 ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
186
187 size = strlen(name) + 1;
188 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
189 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#x.\n", hr);
190 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
191 ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
192
193 size = strlen(name);
194 strcpy(cname, "XXX");
195 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
196 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
197 ok_(__FILE__, line)(size == strlen(name), "Wrong classname size: %u.\n", size);
198 ok_(__FILE__, line)(!strcmp(cname, "XXX"), "Expected unchanged buffer, but got \"%s\".\n", cname);
199}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define IDirect3DRMViewport_GetClassName(p, a, b)
Definition: d3drmobj.h:856
#define IDirect3DRMObject_GetClassName(p, a, b)
Definition: d3drmobj.h:229

◆ test_create_device_1()

static void test_create_device_1 ( void  )
static

Definition at line 5933 of file d3drm.c.

5934{
5935 IDirect3DRM *d3drm = NULL;
5936 IDirect3DRMDevice *device = (IDirect3DRMDevice *)0xdeadbeef;
5937 HRESULT hr;
5938
5940 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
5941
5942 hr = IDirect3DRM_CreateDevice(d3drm, 640, 480, &device);
5943 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == D3DRMERR_BADDEVICE, got %x.\n", hr);
5944 ok(device == NULL, "Expected device returned == NULL, got %p.\n", device);
5945 hr = IDirect3DRM_CreateDevice(d3drm, 640, 480, NULL);
5946 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5947
5949}
#define IDirect3DRM_CreateDevice(p, a, b, c)
Definition: d3drm.h:124
#define D3DRMERR_BADDEVICE
Definition: d3drm.h:495
Definition: d3drm.c:189

Referenced by START_TEST().

◆ test_create_device_2()

static void test_create_device_2 ( void  )
static

Definition at line 5951 of file d3drm.c.

5952{
5953 IDirect3DRM *d3drm = NULL;
5954 IDirect3DRM2 *d3drm2 = NULL;
5955 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
5956 HRESULT hr;
5957
5959 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
5960 hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM2, (void **)&d3drm2);
5961 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
5962
5963 hr = IDirect3DRM2_CreateDevice(d3drm2, 640, 480, &device2);
5964 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == D3DRMERR_BADDEVICE, got %x.\n", hr);
5965 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
5966 hr = IDirect3DRM2_CreateDevice(d3drm2, 640, 480, NULL);
5967 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5968
5969 IDirect3DRM2_Release(d3drm2);
5971}
#define IDirect3DRM2_Release(p)
Definition: d3drm.h:252
#define IDirect3DRM2_CreateDevice(p, a, b, c)
Definition: d3drm.h:265

Referenced by START_TEST().

◆ test_create_device_3()

static void test_create_device_3 ( void  )
static

Definition at line 5973 of file d3drm.c.

5974{
5975 IDirect3DRM *d3drm = NULL;
5976 IDirect3DRM3 *d3drm3 = NULL;
5977 IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
5978 HRESULT hr;
5979
5981 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
5982 hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3);
5983 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
5984
5985 hr = IDirect3DRM3_CreateDevice(d3drm3, 640, 480, &device3);
5986 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == D3DRMERR_BADDEVICE, got %x.\n", hr);
5987 ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
5988 hr = IDirect3DRM3_CreateDevice(d3drm3, 640, 480, NULL);
5989 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5990
5991 IDirect3DRM3_Release(d3drm3);
5993}
#define IDirect3DRM3_CreateDevice(p, a, b, c)
Definition: d3drm.h:413

Referenced by START_TEST().

◆ test_create_device_from_clipper1()

static void test_create_device_from_clipper1 ( void  )
static

Definition at line 3859 of file d3drm.c.

3860{
3861 DDSCAPS caps = { DDSCAPS_ZBUFFER };
3862 IDirect3DRM *d3drm1 = NULL;
3863 IDirectDraw *ddraw = NULL;
3865 IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
3866 IDirect3DDevice *d3ddevice1 = NULL;
3867 IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
3868 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
3869 IDirectDrawSurface7 *surface7 = NULL;
3870 DDSURFACEDESC desc, surface_desc;
3871 DWORD expected_flags, ret_val;
3872 HWND window;
3873 GUID driver = IID_IDirect3DRGBDevice;
3874 HRESULT hr;
3875 ULONG ref1, ref2, cref1, cref2;
3876 RECT rc;
3877
3879 GetClientRect(window, &rc);
3880 hr = DirectDrawCreateClipper(0, &clipper, NULL);
3881 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
3882 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
3883 ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
3884
3885 hr = Direct3DRMCreate(&d3drm1);
3886 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
3887 ref1 = get_refcount((IUnknown *)d3drm1);
3888 cref1 = get_refcount((IUnknown *)clipper);
3889
3890 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 0, 0, &device1);
3891 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3892 ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
3893
3894 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3895 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, NULL, &driver, 300, 200, &device1);
3896 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3897
3898 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 300, 200, NULL);
3899 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
3900
3901 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 300, 200, &device1);
3902 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr);
3903 ref2 = get_refcount((IUnknown *)d3drm1);
3904 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
3905 cref2 = get_refcount((IUnknown *)clipper);
3906 ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
3907 ret_val = IDirect3DRMDevice_GetWidth(device1);
3908 ok(ret_val == 300, "Expected device width = 300, got %u.\n", ret_val);
3909 ret_val = IDirect3DRMDevice_GetHeight(device1);
3910 ok(ret_val == 200, "Expected device height == 200, got %u.\n", ret_val);
3911
3912 /* Fetch immediate mode device in order to access render target */
3913 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
3914 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
3915
3916 hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
3917 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
3918
3919 hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
3920 ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
3921
3922 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3923 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
3924 ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr);
3925 IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
3926 hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
3927 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3928 IUnknown_Release(unknown);
3929 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
3930 NULL, &d3drm_primary, surface_callback);
3931 ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
3932 ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
3933 hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
3934 ok(hr == DD_OK, "Cannot get attached clipper from primary surface (hr = %x).\n", hr);
3935 ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
3936
3937 IDirectDrawClipper_Release(d3drm_clipper);
3938 IDirectDrawSurface_Release(d3drm_primary);
3939 IDirectDrawSurface7_Release(surface7);
3940 IDirectDraw_Release(ddraw);
3941
3942 /* Check properties of render target and depth surface */
3943 surface_desc.dwSize = sizeof(surface_desc);
3944 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
3945 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
3946
3947 ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3948 surface_desc.dwWidth, surface_desc.dwHeight);
3949 ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
3950 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
3952 ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
3953
3955 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
3956 desc.dwSize = sizeof(desc);
3957 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3958 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3959 ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %u bpp, got %u bpp.\n",
3960 surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
3961
3962 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
3963 ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
3964
3965 desc.dwSize = sizeof(desc);
3966 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
3967 ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
3968
3969 ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3970 desc.dwWidth, desc.dwHeight);
3971 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
3973 ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
3974 ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc.dwZBufferBitDepth);
3975 ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
3976
3977 /* Release old objects and check refcount of device and clipper */
3978 IDirectDrawSurface_Release(ds);
3979 ds = NULL;
3980 IDirectDrawSurface_Release(surface);
3981 surface = NULL;
3982 IDirect3DDevice_Release(d3ddevice1);
3983 d3ddevice1 = NULL;
3985 ref2 = get_refcount((IUnknown *)d3drm1);
3986 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
3987 cref2 = get_refcount((IUnknown *)clipper);
3988 ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
3989
3990 /* Test if render target format follows the screen format */
3991 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3992 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3993 hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
3994 ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
3995
3996 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
3997 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
3998 ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
3999
4000 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1);
4001 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr);
4002
4003 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
4004 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
4005
4006 hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
4007 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
4008
4009 surface_desc.dwSize = sizeof(surface_desc);
4010 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4011 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
4012 todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
4013 surface_desc.ddpfPixelFormat.dwRGBBitCount);
4014
4015 hr = IDirectDraw2_RestoreDisplayMode(ddraw);
4016 ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
4017
4018 if (ds)
4019 IDirectDrawSurface_Release(ds);
4020 IDirectDrawSurface_Release(surface);
4021 IDirect3DDevice_Release(d3ddevice1);
4023 IDirect3DRM_Release(d3drm1);
4024 IDirectDrawClipper_Release(clipper);
4025 IDirectDraw_Release(ddraw);
4027}
#define IDirect3DDevice_QueryInterface(p, a, b)
Definition: d3d.h:964
#define IDirect3DDevice_Release(p)
Definition: d3d.h:966
#define IDirect3DRM_CreateDeviceFromClipper(p, a, b, c, d, e)
Definition: d3drm.h:127
#define IDirect3DRMDevice_GetHeight(p)
Definition: d3drmobj.h:435
#define IDirect3DRMDevice_GetDirect3DDevice(p, a)
Definition: d3drmobj.h:442
#define IDirect3DRMDevice_GetWidth(p)
Definition: d3drmobj.h:436
#define IDirect3DRMDevice_Release(p)
Definition: d3drmobj.h:409
HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter)
Definition: main.c:55
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
static HWND create_window(void)
Definition: d3drm.c:149
static HRESULT CALLBACK surface_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
Definition: d3drm.c:3845
struct @1646::@1647 driver
DWORD IDirectDrawSurface7
Definition: vmrender.idl:20
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
#define DDSD_PITCH
Definition: ddraw.h:211
#define DDENUMSURFACES_ALL
Definition: ddraw.h:521
#define DD_OK
Definition: ddraw.h:186
#define DDENUMSURFACES_DOESEXIST
Definition: ddraw.h:525
#define DDERR_NOCLIPPERATTACHED
Definition: ddraw.h:142
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

◆ test_create_device_from_clipper2()

static void test_create_device_from_clipper2 ( void  )
static

Definition at line 4029 of file d3drm.c.

4030{
4031 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4032 IDirect3DRM *d3drm1 = NULL;
4033 IDirect3DRM2 *d3drm2 = NULL;
4034 IDirectDraw *ddraw = NULL;
4036 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
4037 IDirect3DDevice2 *d3ddevice2 = NULL;
4038 IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
4039 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
4040 IDirectDrawSurface7 *surface7 = NULL;
4041 DDSURFACEDESC desc, surface_desc;
4042 DWORD expected_flags, ret_val;
4043 HWND window;
4044 GUID driver = IID_IDirect3DRGBDevice;
4045 HRESULT hr;
4046 ULONG ref1, ref2, ref3, cref1, cref2;
4047 RECT rc;
4048
4050 GetClientRect(window, &rc);
4051 hr = DirectDrawCreateClipper(0, &clipper, NULL);
4052 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
4053 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
4054 ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
4055
4056 hr = Direct3DRMCreate(&d3drm1);
4057 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
4058 ref1 = get_refcount((IUnknown *)d3drm1);
4059 cref1 = get_refcount((IUnknown *)clipper);
4060
4061 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
4062 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr);
4063 ref2 = get_refcount((IUnknown *)d3drm2);
4064
4065 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 0, 0, &device2);
4066 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4067 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
4068
4069 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4070 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, NULL, &driver, 300, 200, &device2);
4071 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4072
4073 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, NULL);
4074 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4075
4076 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, &device2);
4077 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
4078 ref3 = get_refcount((IUnknown *)d3drm1);
4079 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
4080 ref3 = get_refcount((IUnknown *)d3drm2);
4081 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
4082 cref2 = get_refcount((IUnknown *)clipper);
4083 ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
4084 ret_val = IDirect3DRMDevice2_GetWidth(device2);
4085 ok(ret_val == 300, "Expected device width = 300, got %u.\n", ret_val);
4086 ret_val = IDirect3DRMDevice2_GetHeight(device2);
4087 ok(ret_val == 200, "Expected device height == 200, got %u.\n", ret_val);
4088
4089 /* Fetch immediate mode device in order to access render target */
4090 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4091 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
4092
4093 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4094 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
4095
4096 hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
4097 ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
4098
4099 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4100 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
4101 ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr);
4102 IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
4103 hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
4104 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
4105 IUnknown_Release(unknown);
4106 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4107 NULL, &d3drm_primary, surface_callback);
4108 ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
4109 ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
4110 hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
4111 ok(hr == DD_OK, "Cannot get attached clipper from primary surface (hr = %x).\n", hr);
4112 ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
4113
4114 IDirectDrawClipper_Release(d3drm_clipper);
4115 IDirectDrawSurface_Release(d3drm_primary);
4116 IDirectDrawSurface7_Release(surface7);
4117 IDirectDraw_Release(ddraw);
4118
4119 /* Check properties of render target and depth surface */
4120 surface_desc.dwSize = sizeof(surface_desc);
4121 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4122 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
4123
4124 ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
4125 surface_desc.dwWidth, surface_desc.dwHeight);
4126 ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
4127 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
4129 ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
4130
4132 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
4133 desc.dwSize = sizeof(desc);
4134 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4135 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
4136 ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %u bpp, got %u bpp.\n",
4137 surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
4138
4139 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4140 ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
4141
4142 desc.dwSize = sizeof(desc);
4143 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4144 ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
4145
4146 ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
4147 desc.dwWidth, desc.dwHeight);
4148 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
4150 ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
4151 ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc.dwZBufferBitDepth);
4152 ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
4153
4154 /* Release old objects and check refcount of device and clipper */
4155 IDirectDrawSurface_Release(ds);
4156 ds = NULL;
4157 IDirectDrawSurface_Release(surface);
4158 surface = NULL;
4159 IDirect3DDevice2_Release(d3ddevice2);
4160 d3ddevice2 = NULL;
4162 ref3 = get_refcount((IUnknown *)d3drm1);
4163 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
4164 ref3 = get_refcount((IUnknown *)d3drm2);
4165 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
4166 cref2 = get_refcount((IUnknown *)clipper);
4167 ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
4168
4169 /* Test if render target format follows the screen format */
4170 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4171 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
4172 hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
4173 ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
4174
4175 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4176 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
4177 ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
4178
4179 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, rc.right, rc.bottom, &device2);
4180 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
4181
4182 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4183 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
4184
4185 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4186 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
4187
4188 surface_desc.dwSize = sizeof(surface_desc);
4189 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4190 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
4191 todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
4192 surface_desc.ddpfPixelFormat.dwRGBBitCount);
4193
4194 hr = IDirectDraw2_RestoreDisplayMode(ddraw);
4195 ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
4196
4197 IDirectDrawSurface_Release(surface);
4198 IDirect3DDevice2_Release(d3ddevice2);
4200 IDirect3DRM2_Release(d3drm2);
4201 IDirect3DRM_Release(d3drm1);
4202 IDirectDrawClipper_Release(clipper);
4203 IDirectDraw_Release(ddraw);
4205}
#define IDirect3DDevice2_GetRenderTarget(p, a)
Definition: d3d.h:1079
#define IDirect3DDevice2_Release(p)
Definition: d3d.h:1064
#define IDirect3DRM2_CreateDeviceFromClipper(p, a, b, c, d, e)
Definition: d3drm.h:268
#define IDirect3DRMDevice2_GetHeight(p)
Definition: d3drmobj.h:568
#define IDirect3DRMDevice2_Release(p)
Definition: d3drmobj.h:542
#define IDirect3DRMDevice2_GetDirect3DDevice2(p, a)
Definition: d3drmobj.h:581
#define IDirect3DRMDevice2_GetWidth(p)
Definition: d3drmobj.h:569

Referenced by START_TEST().

◆ test_create_device_from_clipper3()

static void test_create_device_from_clipper3 ( void  )
static

Definition at line 4207 of file d3drm.c.

4208{
4209 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4210 IDirect3DRM *d3drm1 = NULL;
4211 IDirect3DRM3 *d3drm3 = NULL;
4212 IDirectDraw *ddraw = NULL;
4214 IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
4215 IDirect3DDevice2 *d3ddevice2 = NULL;
4216 IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
4217 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
4218 IDirectDrawSurface7 *surface7 = NULL;
4219 DDSURFACEDESC desc, surface_desc;
4220 DWORD expected_flags, ret_val;
4221 HWND window;
4222 GUID driver = IID_IDirect3DRGBDevice;
4223 HRESULT hr;
4224 ULONG ref1, ref2, ref3, cref1, cref2;
4225 RECT rc;
4226
4228 GetClientRect(window, &rc);
4229 hr = DirectDrawCreateClipper(0, &clipper, NULL);
4230 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
4231 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
4232 ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
4233
4234 hr = Direct3DRMCreate(&d3drm1);
4235 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
4236 ref1 = get_refcount((IUnknown *)d3drm1);
4237 cref1 = get_refcount((IUnknown *)clipper);
4238
4239 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
4240 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
4241 ref2 = get_refcount((IUnknown *)d3drm3);
4242
4243 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 0, 0, &device3);
4244 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4245 ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
4246
4247 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4248 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, NULL, &driver, 300, 200, &device3);
4249 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4250
4251 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 300, 200, NULL);
4252 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
4253
4254 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 300, 200, &device3);
4255 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr);
4256 ref3 = get_refcount((IUnknown *)d3drm1);
4257 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
4258 ref3 = get_refcount((IUnknown *)d3drm3);
4259 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
4260 cref2 = get_refcount((IUnknown *)clipper);
4261 ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
4262 ret_val = IDirect3DRMDevice3_GetWidth(device3);
4263 ok(ret_val == 300, "Expected device width = 300, got %u.\n", ret_val);
4264 ret_val = IDirect3DRMDevice3_GetHeight(device3);
4265 ok(ret_val == 200, "Expected device height == 200, got %u.\n", ret_val);
4266
4267 /* Fetch immediate mode device in order to access render target */
4268 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4269 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
4270
4271 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4272 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
4273
4274 hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
4275 ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
4276
4277 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4278 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
4279 ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr);
4280 IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
4281 hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
4282 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
4283 IUnknown_Release(unknown);
4284 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4285 NULL, &d3drm_primary, surface_callback);
4286 ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
4287 ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
4288 hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
4289 ok(hr == DD_OK, "Cannot get attached clipper from primary surface (hr = %x).\n", hr);
4290 ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
4291
4292 IDirectDrawClipper_Release(d3drm_clipper);
4293 IDirectDrawSurface_Release(d3drm_primary);
4294 IDirectDrawSurface7_Release(surface7);
4295 IDirectDraw_Release(ddraw);
4296
4297 /* Check properties of render target and depth surface */
4298 surface_desc.dwSize = sizeof(surface_desc);
4299 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4300 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
4301
4302 ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
4303 surface_desc.dwWidth, surface_desc.dwHeight);
4304 ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
4305 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
4307 ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
4308
4310 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
4311 desc.dwSize = sizeof(desc);
4312 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4313 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
4314 ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %u bpp, got %u bpp.\n",
4315 surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
4316
4317 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4318 ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
4319
4320 desc.dwSize = sizeof(desc);
4321 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4322 ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
4323
4324 ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
4325 desc.dwWidth, desc.dwHeight);
4326 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
4328 ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
4329 ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc.dwZBufferBitDepth);
4330 ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
4331
4332 /* Release old objects and check refcount of device and clipper */
4333 IDirectDrawSurface_Release(ds);
4334 ds = NULL;
4335 IDirectDrawSurface_Release(surface);
4336 surface = NULL;
4337 IDirect3DDevice2_Release(d3ddevice2);
4338 d3ddevice2 = NULL;
4340 ref3 = get_refcount((IUnknown *)d3drm1);
4341 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
4342 ref3 = get_refcount((IUnknown *)d3drm3);
4343 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
4344 cref2 = get_refcount((IUnknown *)clipper);
4345 ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
4346
4347 /* Test if render target format follows the screen format */
4348 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4349 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
4350 hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
4351 ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
4352
4353 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4354 ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
4355 ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
4356
4357 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
4358 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr);
4359
4360 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4361 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
4362
4363 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4364 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
4365
4366 surface_desc.dwSize = sizeof(surface_desc);
4367 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4368 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
4369 todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
4370 surface_desc.ddpfPixelFormat.dwRGBBitCount);
4371
4372 hr = IDirectDraw2_RestoreDisplayMode(ddraw);
4373 ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
4374
4375 IDirectDrawSurface_Release(surface);
4376 IDirect3DDevice2_Release(d3ddevice2);
4378 IDirect3DRM3_Release(d3drm3);
4379 IDirect3DRM_Release(d3drm1);
4380 IDirectDrawClipper_Release(clipper);
4381 IDirectDraw_Release(ddraw);
4383}
#define IDirect3DRM3_CreateDeviceFromClipper(p, a, b, c, d, e)
Definition: d3drm.h:416
#define IDirect3DRMDevice3_Release(p)
Definition: d3drmobj.h:693
#define IDirect3DRMDevice3_GetHeight(p)
Definition: d3drmobj.h:719
#define IDirect3DRMDevice3_GetDirect3DDevice2(p, a)
Definition: d3drmobj.h:732
#define IDirect3DRMDevice3_GetWidth(p)
Definition: d3drmobj.h:720

Referenced by START_TEST().

◆ test_create_device_from_d3d1()

static void test_create_device_from_d3d1 ( void  )
static

Definition at line 5034 of file d3drm.c.

5035{
5036 IDirectDraw *ddraw1 = NULL, *temp_ddraw1;
5037 IDirect3D *d3d1 = NULL, *temp_d3d1;
5038 IDirect3DRM *d3drm1 = NULL;
5039 IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
5040 IDirect3DRMDevice2 *device2;
5041 IDirect3DRMDevice3 *device3;
5042 IDirect3DDevice *d3ddevice1 = NULL, *d3drm_d3ddevice1 = NULL, *temp_d3ddevice1;
5043 IDirect3DDevice2 *d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5044 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
5045 DWORD expected_flags, ret_val;
5046 DDSCAPS caps = { DDSCAPS_ZBUFFER };
5048 RECT rc;
5049 HWND window;
5050 ULONG ref1, ref2, ref3, ref4, device_ref1, device_ref2, d3d_ref1, d3d_ref2;
5051 HRESULT hr;
5052
5053 hr = DirectDrawCreate(NULL, &ddraw1, NULL);
5054 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
5055
5057 GetClientRect(window, &rc);
5058
5059 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D, (void **)&d3d1);
5060 ok(hr == DD_OK, "Cannot get IDirect3D2 interface (hr = %x).\n", hr);
5061 d3d_ref1 = get_refcount((IUnknown *)d3d1);
5062
5063 /* Create the immediate mode device */
5064 d3ddevice1 = create_device1(ddraw1, window, &ds);
5065 if (d3ddevice1 == NULL)
5066 {
5067 win_skip("Cannot create IM device, skipping tests.\n");
5068 IDirect3D_Release(d3d1);
5069 IDirectDraw_Release(ddraw1);
5070 return;
5071 }
5072 device_ref1 = get_refcount((IUnknown *)d3ddevice1);
5073
5074 hr = Direct3DRMCreate(&d3drm1);
5075 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
5076 ref1 = get_refcount((IUnknown *)d3drm1);
5077
5078 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, NULL, d3ddevice1, &device1);
5079 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5080 ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
5081 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, NULL, &device1);
5082 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5083 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, NULL);
5084 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5085
5086 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, &device1);
5087 ok(hr == DD_OK, "Failed to create IDirect3DRMDevice interface (hr = %x)\n", hr);
5088 ref2 = get_refcount((IUnknown *)d3drm1);
5089 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
5090 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5091 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2);
5092 d3d_ref2 = get_refcount((IUnknown *)d3d1);
5093 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1, d3d_ref2);
5094 ret_val = IDirect3DRMDevice_GetWidth(device1);
5095 ok(ret_val == rc.right, "Expected device width = 300, got %u.\n", ret_val);
5096 ret_val = IDirect3DRMDevice_GetHeight(device1);
5097 ok(ret_val == rc.bottom, "Expected device height == 200, got %u.\n", ret_val);
5098
5099 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2);
5100 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr);
5101 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
5102 ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got %#x.\n", hr);
5103 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5105
5106 d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5107 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3);
5108 ok(hr == DD_OK, "Cannot get IDirect3DRMDevice3 Interface (hr = %x).\n", hr);
5109 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5110 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
5111 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5113
5114 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5115 NULL, &surface, surface_callback);
5116 ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
5117 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5118
5119 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
5120 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
5121 ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice1, d3drm_d3ddevice1);
5122
5123 /* Check properties of render target and depth surfaces */
5124 hr = IDirect3DDevice_QueryInterface(d3drm_d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
5125 ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
5126
5127 memset(&desc, 0, sizeof(desc));
5128 desc.dwSize = sizeof(desc);
5129 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5130 ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
5131
5132 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5133 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5135 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, desc.ddsCaps.dwCaps);
5137 ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
5138
5139 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5140 ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
5141 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5142
5143 desc.dwSize = sizeof(desc);
5144 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5145 ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
5146
5147 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5148 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5149 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
5151 ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
5152
5153 IDirectDrawSurface_Release(d3drm_ds);
5154 IDirectDrawSurface_Release(ds);
5155 IDirectDrawSurface_Release(surface);
5156 IDirect3DDevice_Release(d3drm_d3ddevice1);
5158 ref2 = get_refcount((IUnknown *)d3drm1);
5159 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
5160 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5161 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2);
5162
5163 /* InitFromD3D tests */
5164 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice, (void **)&device1);
5165 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr);
5166
5167 hr = IDirect3DRMDevice_InitFromD3D(device1, NULL, d3ddevice1);
5168 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
5169 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, NULL);
5170 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
5171
5172 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
5173 ok(SUCCEEDED(hr), "Failed to initialise IDirect3DRMDevice interface (hr = %#x)\n", hr);
5174 ref2 = get_refcount((IUnknown *)d3drm1);
5175 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
5176 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5177 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5178 device_ref1, device_ref2);
5179 d3d_ref2 = get_refcount((IUnknown *)d3d1);
5180 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1, d3d_ref2);
5181 ret_val = IDirect3DRMDevice_GetWidth(device1);
5182 ok(ret_val == rc.right, "Expected device width = 300, got %u.\n", ret_val);
5183 ret_val = IDirect3DRMDevice_GetHeight(device1);
5184 ok(ret_val == rc.bottom, "Expected device height == 200, got %u.\n", ret_val);
5185
5186 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
5187 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
5188 ref3 = get_refcount((IUnknown *)d3drm1);
5189 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
5190 ref3 = get_refcount((IUnknown *)d3ddevice1);
5191 ok(ref3 > device_ref2, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3, device_ref2);
5192 ref3 = get_refcount((IUnknown *)d3d1);
5193 ok(ref3 > d3d_ref2, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3, d3d_ref2);
5194 /* Release leaked references */
5195 while (IDirect3DRM_Release(d3drm1) > ref2);
5196 while (IDirect3DDevice_Release(d3ddevice1) > device_ref2);
5197 while (IDirect3D_Release(d3d1) > d3d_ref2);
5198
5199 hr = DirectDrawCreate(NULL, &temp_ddraw1, NULL);
5200 ok(SUCCEEDED(hr), "Cannot get IDirectDraw interface (hr = %#x).\n", hr);
5201 ref4 = get_refcount((IUnknown *)temp_ddraw1);
5202
5203 hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirect3D, (void **)&temp_d3d1);
5204 ok(SUCCEEDED(hr), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr);
5205 temp_d3ddevice1 = create_device1(temp_ddraw1, window, &surface);
5206 hr = IDirect3DRMDevice_InitFromD3D(device1, temp_d3d1, temp_d3ddevice1);
5207 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
5208 ref3 = get_refcount((IUnknown *)d3drm1);
5209 ok(ref3 > ref2, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
5210 ref3 = get_refcount((IUnknown *)temp_d3ddevice1);
5211 ok(ref3 == device_ref2, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3, device_ref2);
5212 ref3 = get_refcount((IUnknown *)temp_d3d1);
5213 todo_wine ok(ref3 < d3d_ref2, "Expected ref3 < d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3, d3d_ref2);
5214 /* Release leaked references */
5215 while (IDirect3DRM_Release(d3drm1) > ref2);
5216 while (IDirect3DDevice_Release(temp_d3ddevice1) > 0);
5217 while (IDirect3D_Release(temp_d3d1) > ref4);
5218 IDirectDrawSurface_Release(surface);
5219 IDirectDraw_Release(temp_ddraw1);
5220
5221 d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5222 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2);
5223 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr);
5224 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
5225 ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got %#x.\n", hr);
5226 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5228
5229 d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5230 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3);
5231 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 Interface (hr = %#x).\n", hr);
5232 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5233 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
5234 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5236
5237 surface = NULL;
5238 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5239 NULL, &surface, surface_callback);
5240 ok(SUCCEEDED(hr), "Failed to enumerate surfaces (hr = %#x).\n", hr);
5241 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5242
5243 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
5244 ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice interface (hr = %#x).\n", hr);
5245 ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode device created == %p, got %p.\n",
5246 d3ddevice1, d3drm_d3ddevice1);
5247
5248 /* Check properties of render target and depth surfaces */
5249 hr = IDirect3DDevice_QueryInterface(d3drm_d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
5250 ok(SUCCEEDED(hr), "Cannot get surface to the render target (hr = %#x).\n", hr);
5251
5252 memset(&desc, 0, sizeof(desc));
5253 desc.dwSize = sizeof(desc);
5254 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5255 ok(SUCCEEDED(hr), "Cannot get surface desc structure (hr = %#x).\n", hr);
5256
5257 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5258 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5260 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, desc.ddsCaps.dwCaps);
5262 ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
5263
5264 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5265 ok(SUCCEEDED(hr), "Cannot get attached depth surface (hr = %x).\n", hr);
5266 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5267
5268 desc.dwSize = sizeof(desc);
5269 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5270 ok(SUCCEEDED(hr), "Cannot get z surface desc structure (hr = %#x).\n", hr);
5271
5272 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5273 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5274 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %#x, got %#x.\n",
5275 DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
5277 ok(desc.dwFlags == expected_flags, "Expected %#x for flags, got %#x.\n", expected_flags, desc.dwFlags);
5278
5279 IDirectDrawSurface_Release(d3drm_ds);
5280 IDirectDrawSurface_Release(ds);
5281 IDirectDrawSurface_Release(surface);
5282 IDirect3DDevice_Release(d3drm_d3ddevice1);
5284 ref2 = get_refcount((IUnknown *)d3drm1);
5285 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
5286 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5287 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5288 device_ref1, device_ref2);
5289 d3d_ref2 = get_refcount((IUnknown *)d3d1);
5290 todo_wine ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1,
5291 d3d_ref2);
5292
5293 IDirect3DRM_Release(d3drm1);
5294 IDirect3DDevice_Release(d3ddevice1);
5295 IDirect3D_Release(d3d1);
5296 IDirectDraw_Release(ddraw1);
5298}
#define IDirect3D_Release(p)
Definition: d3d.h:233
#define IDirect3DRM_CreateObject(p, a, b, c, d)
Definition: d3drm.h:113
#define IDirect3DRM_CreateDeviceFromD3D(p, a, b, c)
Definition: d3drm.h:126
#define D3DRMERR_BADOBJECT
Definition: d3drm.h:487
#define IDirect3DRMDevice_InitFromD3D(p, a, b)
Definition: d3drmobj.h:421
#define IDirect3DRMDevice_QueryInterface(p, a, b)
Definition: d3drmobj.h:407
static IDirect3DDevice * create_device1(IDirectDraw *ddraw, HWND window, IDirectDrawSurface **ds)
Definition: d3drm.c:4975
#define win_skip
Definition: test.h:160

Referenced by START_TEST().

◆ test_create_device_from_d3d2()

static void test_create_device_from_d3d2 ( void  )
static

Definition at line 5369 of file d3drm.c.

5370{
5371 IDirectDraw *ddraw1 = NULL, *temp_ddraw1;
5372 IDirectDraw2 *ddraw2 = NULL, *temp_ddraw2;
5373 IDirect3D* d3d1;
5374 IDirect3D2 *d3d2 = NULL, *temp_d3d2;
5375 IDirect3DRM *d3drm1 = NULL;
5376 IDirect3DRM2 *d3drm2 = NULL;
5377 IDirect3DRMDevice *device1;
5378 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
5379 IDirect3DDevice *d3ddevice1;
5380 IDirect3DDevice2 *d3ddevice2 = NULL, *d3drm_d3ddevice2 = NULL, *temp_d3ddevice2;
5381 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
5382 DWORD expected_flags, ret_val;
5383 DDSCAPS caps = { DDSCAPS_ZBUFFER };
5385 RECT rc;
5386 HWND window;
5387 ULONG ref1, ref2, ref3, ref4, ref5, device_ref1, device_ref2, d3d_ref1, d3d_ref2;
5388 HRESULT hr;
5389
5390 hr = DirectDrawCreate(NULL, &ddraw1, NULL);
5391 ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
5392
5394 GetClientRect(window, &rc);
5395
5396 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D2, (void **)&d3d2);
5397 ok(hr == DD_OK, "Cannot get IDirect3D2 interface (hr = %x).\n", hr);
5398 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
5399 ok(hr == DD_OK, "Cannot get IDirectDraw2 interface (hr = %x).\n", hr);
5400 d3d_ref1 = get_refcount((IUnknown *)d3d2);
5401
5402 /* Create the immediate mode device */
5403 d3ddevice2 = create_device2(ddraw2, window, &ds);
5404 if (d3ddevice2 == NULL)
5405 {
5406 win_skip("Cannot create IM device, skipping tests.\n");
5407 IDirect3D2_Release(d3d2);
5408 IDirectDraw2_Release(ddraw2);
5409 IDirectDraw_Release(ddraw1);
5410 return;
5411 }
5412 device_ref1 = get_refcount((IUnknown *)d3ddevice2);
5413
5414 hr = Direct3DRMCreate(&d3drm1);
5415 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
5416 ref1 = get_refcount((IUnknown *)d3drm1);
5417
5418 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
5419 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr);
5420 ref2 = get_refcount((IUnknown *)d3drm2);
5421
5422 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, NULL, d3ddevice2, &device2);
5423 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5424 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
5425 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, d3d2, NULL, &device2);
5426 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5427 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, d3d2, d3ddevice2, NULL);
5428 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
5429
5430 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, d3d2, d3ddevice2, &device2);
5431 ok(hr == DD_OK, "Failed to create IDirect3DRMDevice2 interface (hr = %x)\n", hr);
5432 ref3 = get_refcount((IUnknown *)d3drm1);
5433 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
5434 ref3 = get_refcount((IUnknown *)d3drm2);
5435 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
5436 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5437 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2);
5438 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5439 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1, d3d_ref2);
5440 ret_val = IDirect3DRMDevice2_GetWidth(device2);
5441 ok(ret_val == rc.right, "Expected device width = 300, got %u.\n", ret_val);
5442 ret_val = IDirect3DRMDevice2_GetHeight(device2);
5443 ok(ret_val == rc.bottom, "Expected device height == 200, got %u.\n", ret_val);
5444
5445 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5446 NULL, &surface, surface_callback);
5447 ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
5448 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5449
5450 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3drm_d3ddevice2);
5451 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
5452 ok(d3ddevice2 == d3drm_d3ddevice2, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2, d3drm_d3ddevice2);
5453
<