ReactOS 0.4.17-dev-966-gf06eace
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)
 
#define MOD_R   247
 
#define MOD_G   239
 
#define MOD_B   251
 

Functions

static ULONG get_refcount (IUnknown *object)
 
static BOOL compare_uint (unsigned int x, unsigned int y, unsigned int max_diff)
 
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 BOOL compare_color (D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
 
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 char * create_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 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 GUID * refiids []
 
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 67 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 93 of file d3drm.c.

◆ MOD_B

#define MOD_B   251

Definition at line 6164 of file d3drm.c.

◆ MOD_G

#define MOD_G   239

Definition at line 6163 of file d3drm.c.

◆ MOD_R

#define MOD_R   247

Definition at line 6162 of file d3drm.c.

◆ test_class_name

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

Definition at line 171 of file d3drm.c.

◆ test_object_name

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

Definition at line 213 of file d3drm.c.

◆ vector_eq

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

Definition at line 104 of file d3drm.c.

Function Documentation

◆ clear_depth_surface()

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

Definition at line 6873 of file d3drm.c.

6874{
6875 HRESULT hr;
6876 DDBLTFX fx;
6877
6878 memset(&fx, 0, sizeof(fx));
6879 fx.dwSize = sizeof(fx);
6880 fx.dwFillDepth = value;
6881
6882 hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
6883 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
6884}
#define ok(value,...)
Definition: atltest.h:57
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define DDBLT_WAIT
Definition: ddraw.h:571
#define DDBLT_DEPTHFILL
Definition: ddraw.h:572
#define memset(x, y, z)
Definition: compat.h:39
GLfixed fx
Definition: tritemp.h:484
Definition: pdh_main.c:64

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

111{
112 return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
113 && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff)
114 && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff)
115 && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
116}
static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
Definition: d3drm.c:47

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

55{
56 int x = *(int *)&f;
57 int y = *(int *)&g;
58
59 if (x < 0)
60 x = INT_MIN - x;
61 if (y < 0)
62 y = INT_MIN - y;
63
64 return compare_uint(x, y, ulps);
65}
#define INT_MIN
Definition: limits.h:25
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
unsigned int ulps
Definition: effect.c:4467

◆ compare_uint()

static BOOL compare_uint ( unsigned int  x,
unsigned int  y,
unsigned int  max_diff 
)
static

Definition at line 47 of file d3drm.c.

48{
49 unsigned int diff = x > y ? x - y : y - x;
50
51 return diff <= max_diff;
52}

Referenced by compare_color(), and compare_float().

◆ create_bitmap()

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

Definition at line 6166 of file d3drm.c.

6167{
6168 unsigned int bpp = palettized ? 8 : 24;
6170 DWORD written, size, ret;
6171 unsigned char *buffer;
6172 char path[MAX_PATH];
6173 unsigned int i, j;
6175 char *filename;
6176 HANDLE file;
6177
6179 ok(ret, "Failed to get temporary file path.\n");
6181 ret = GetTempFileNameA(path, "d3d", 0, filename);
6182 ok(ret, "Failed to get filename.\n");
6184 ok(file != INVALID_HANDLE_VALUE, "Failed to open temporary file \"%s\".\n", filename);
6185
6186 size = FIELD_OFFSET(BITMAPINFO, bmiColors[palettized ? 256 : 0]);
6187
6188 memset(&file_header, 0, sizeof(file_header));
6189 file_header.bfType = 0x4d42; /* BM */
6190 file_header.bfOffBits = sizeof(file_header) + size;
6191 file_header.bfSize = file_header.bfOffBits + w * h * (bpp / 8);
6192 ret = WriteFile(file, &file_header, sizeof(file_header), &written, NULL);
6193 ok(ret && written == sizeof(file_header), "Failed to write file header.\n");
6194
6195 info = calloc(1, size);
6196 info->bmiHeader.biSize = sizeof(info->bmiHeader);
6197 info->bmiHeader.biBitCount = bpp;
6198 info->bmiHeader.biPlanes = 1;
6199 info->bmiHeader.biWidth = w;
6200 info->bmiHeader.biHeight = h;
6201 info->bmiHeader.biCompression = BI_RGB;
6202 if (palettized)
6203 {
6204 for (i = 0; i < 256; ++i)
6205 {
6206 info->bmiColors[i].rgbBlue = i % MOD_B;
6207 info->bmiColors[i].rgbGreen = i % MOD_G;
6208 info->bmiColors[i].rgbRed = i % MOD_R;
6209 }
6210 }
6211 ret = WriteFile(file, info, size, &written, NULL);
6212 ok(ret && written == size, "Failed to write bitmap info.\n");
6213 free(info);
6214
6215 size = w * h * (bpp / 8);
6216 buffer = calloc(1, size);
6217 for (i = 0, j = 0; i < size;)
6218 {
6219 if (palettized)
6220 {
6221 buffer[i++] = j++;
6222 j %= 256;
6223 }
6224 else
6225 {
6226 buffer[i++] = j % MOD_B;
6227 buffer[i++] = j % MOD_G;
6228 buffer[i++] = j++ % MOD_R;
6229 }
6230 }
6231 ret = WriteFile(file, buffer, size, &written, NULL);
6232 ok(ret && written == size, "Failed to write bitmap data.\n");
6233 free(buffer);
6234
6236
6237 return filename;
6238}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2072
return ret
Definition: mutex.c:147
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
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
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
#define MOD_G
Definition: d3drm.c:6163
#define MOD_B
Definition: d3drm.c:6164
#define MOD_R
Definition: d3drm.c:6162
static const DWORD file_header[]
Definition: mciwnd.c:28
#define GENERIC_WRITE
Definition: nt_native.h:90
#define calloc
Definition: rosglue.h:14
Definition: fci.c:123
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define BI_RGB
Definition: uefivid.c:46
ULONG bpp[]
Definition: xlate.c:19

◆ create_device1()

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

Definition at line 5145 of file d3drm.c.

5146{
5147 static const DWORD z_depths[] = { 32, 24, 16 };
5148 IDirectDrawSurface *surface;
5149 IDirect3DDevice *device = NULL;
5150 DDSURFACEDESC surface_desc;
5151 unsigned int i;
5152 HRESULT hr;
5153 RECT rc;
5154
5155 GetClientRect(window, &rc);
5156 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
5157 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
5158
5159 memset(&surface_desc, 0, sizeof(surface_desc));
5160 surface_desc.dwSize = sizeof(surface_desc);
5161 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
5162 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
5163 surface_desc.dwWidth = rc.right;
5164 surface_desc.dwHeight = rc.bottom;
5165
5166 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
5167 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
5168
5169 /* We used to use EnumDevices() for this, but it seems
5170 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
5171 * relationship with reality. */
5172 for (i = 0; i < ARRAY_SIZE(z_depths); ++i)
5173 {
5174 memset(&surface_desc, 0, sizeof(surface_desc));
5175 surface_desc.dwSize = sizeof(surface_desc);
5176 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
5177 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
5178 surface_desc.dwZBufferBitDepth = z_depths[i];
5179 surface_desc.dwWidth = rc.right;
5180 surface_desc.dwHeight = rc.bottom;
5181 if (FAILED(IDirectDraw_CreateSurface(ddraw, &surface_desc, ds, NULL)))
5182 continue;
5183
5184 hr = IDirectDrawSurface_AddAttachedSurface(surface, *ds);
5185 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
5186 if (FAILED(hr))
5187 {
5188 IDirectDrawSurface_Release(*ds);
5189 continue;
5190 }
5191
5192 if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DHALDevice, (void **)&device)))
5193 break;
5194
5195 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, *ds);
5196 IDirectDrawSurface_Release(*ds);
5197 *ds = NULL;
5198 }
5199
5200 IDirectDrawSurface_Release(surface);
5201 return device;
5202}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define ds
Definition: i386-dis.c:443
#define FAILED(hr)
Definition: intsafe.h:51
static IHTMLWindow2 * window
Definition: events.c:77
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DDSD_WIDTH
Definition: ddraw.h:212
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:269
#define DDSCL_NORMAL
Definition: ddraw.h:537
#define DDSD_HEIGHT
Definition: ddraw.h:211
#define DDSD_ZBUFFERBITDEPTH
Definition: ddraw.h:215
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:257
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:265
#define DDSD_CAPS
Definition: ddraw.h:210
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
Definition: devices.h:37

Referenced by test_create_device_from_d3d1().

◆ create_device2()

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

Definition at line 5469 of file d3drm.c.

5470{
5471 static const DWORD z_depths[] = { 32, 24, 16 };
5472 IDirectDrawSurface *surface;
5473 IDirect3DDevice2 *device = NULL;
5474 DDSURFACEDESC surface_desc;
5475 IDirect3D2 *d3d;
5476 unsigned int i;
5477 HRESULT hr;
5478 RECT rc;
5479
5480 GetClientRect(window, &rc);
5481 hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
5482 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
5483
5484 memset(&surface_desc, 0, sizeof(surface_desc));
5485 surface_desc.dwSize = sizeof(surface_desc);
5486 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
5487 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
5488 surface_desc.dwWidth = rc.right;
5489 surface_desc.dwHeight = rc.bottom;
5490
5491 hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
5492 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
5493
5494 hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
5495 if (FAILED(hr))
5496 {
5497 IDirectDrawSurface_Release(surface);
5498 *ds = NULL;
5499 return NULL;
5500 }
5501
5502 /* We used to use EnumDevices() for this, but it seems
5503 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
5504 * relationship with reality. */
5505 for (i = 0; i < ARRAY_SIZE(z_depths); ++i)
5506 {
5507 memset(&surface_desc, 0, sizeof(surface_desc));
5508 surface_desc.dwSize = sizeof(surface_desc);
5509 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
5510 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
5511 surface_desc.dwZBufferBitDepth = z_depths[i];
5512 surface_desc.dwWidth = rc.right;
5513 surface_desc.dwHeight = rc.bottom;
5514 if (FAILED(IDirectDraw2_CreateSurface(ddraw, &surface_desc, ds, NULL)))
5515 continue;
5516
5517 hr = IDirectDrawSurface_AddAttachedSurface(surface, *ds);
5518 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
5519 if (FAILED(hr))
5520 {
5521 IDirectDrawSurface_Release(*ds);
5522 continue;
5523 }
5524
5525 if (SUCCEEDED(IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device)))
5526 break;
5527
5528 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, *ds);
5529 IDirectDrawSurface_Release(*ds);
5530 *ds = NULL;
5531 }
5532
5533 IDirect3D2_Release(d3d);
5534 IDirectDrawSurface_Release(surface);
5535 return device;
5536}
#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 6836 of file d3drm.c.

6837{
6838 IDirectDrawSurface *surface;
6839 IDirect3DDevice2 *device = NULL;
6840 DDSURFACEDESC surface_desc;
6841 IDirect3D2 *d3d;
6842 HRESULT hr;
6843 RECT rc;
6844
6845 GetClientRect(window, &rc);
6846 hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
6847 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
6848
6849 memset(&surface_desc, 0, sizeof(surface_desc));
6850 surface_desc.dwSize = sizeof(surface_desc);
6851 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
6852 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
6853 surface_desc.dwWidth = rc.right;
6854 surface_desc.dwHeight = rc.bottom;
6855
6856 hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
6857 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
6858
6859 hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
6860 if (FAILED(hr))
6861 {
6862 IDirectDrawSurface_Release(surface);
6863 return NULL;
6864 }
6865
6866 IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device);
6867
6868 IDirect3D2_Release(d3d);
6869 IDirectDrawSurface_Release(surface);
6870 return device;
6871}

Referenced by test_viewport_clear2().

◆ create_window()

static HWND create_window ( void  )
static

Definition at line 161 of file d3drm.c.

162{
163 RECT r = {0, 0, 640, 480};
164
166
167 return CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
168 CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
169}
#define FALSE
Definition: types.h:117
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:4469
#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 6983 of file d3drm.c.

6984{
6985 IDirect3DExecuteBuffer *execute_buffer;
6986 D3DEXECUTEBUFFERDESC exec_desc;
6987 HRESULT hr;
6988 void *ptr;
6989 UINT inst_length;
6990 D3DMATRIXHANDLE world_handle, view_handle, proj_handle;
6991 static D3DMATRIX mat =
6992 {
6993 1.0f, 0.0f, 0.0f, 0.0f,
6994 0.0f, 1.0f, 0.0f, 0.0f,
6995 0.0f, 0.0f, 1.0f, 0.0f,
6996 0.0f, 0.0f, 0.0f, 1.0f,
6997 };
6998 static const D3DLVERTEX quad_strip[] =
6999 {
7000 {{-1.0f}, {-1.0f}, {0.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
7001 {{-1.0f}, { 1.0f}, {0.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
7002 {{ 1.0f}, {-1.0f}, {1.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
7003 {{ 1.0f}, { 1.0f}, {1.00f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
7004 };
7005
7006 hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
7007 ok(hr == D3D_OK, "Creating a matrix object failed, hr %#lx.\n", hr);
7008 hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat);
7009 ok(hr == D3D_OK, "Setting a matrix object failed, hr %#lx.\n", hr);
7010 hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
7011 ok(hr == D3D_OK, "Creating a matrix object failed, hr %#lx.\n", hr);
7012 hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat);
7013 ok(hr == D3D_OK, "Setting a matrix object failed, hr %#lx.\n", hr);
7014 hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
7015 ok(hr == D3D_OK, "Creating a matrix object failed, hr %#lx.\n", hr);
7016 hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat);
7017 ok(hr == D3D_OK, "Setting a matrix object failed, hr %#lx.\n", hr);
7018
7019 memset(&exec_desc, 0, sizeof(exec_desc));
7020 exec_desc.dwSize = sizeof(exec_desc);
7021 exec_desc.dwFlags = D3DDEB_BUFSIZE | D3DDEB_CAPS;
7022 exec_desc.dwBufferSize = 1024;
7023 exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
7024
7025 hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
7026 ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
7027
7028 hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
7029 ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
7030
7031 memcpy(exec_desc.lpData, quad_strip, sizeof(quad_strip));
7032 ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad_strip);
7033 emit_set_ts(&ptr, D3DTRANSFORMSTATE_WORLD, world_handle);
7034 emit_set_ts(&ptr, D3DTRANSFORMSTATE_VIEW, view_handle);
7041
7043 emit_tquad(&ptr, 0);
7044
7045 emit_end(&ptr);
7046 inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
7047 inst_length -= sizeof(quad_strip);
7048
7049 hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
7050 ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
7051
7053 set_execute_data(execute_buffer, 4, sizeof(quad_strip), inst_length);
7054 hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
7055 ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
7057 ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
7058
7059 IDirect3DExecuteBuffer_Release(execute_buffer);
7060}
@ 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 D3DEXECUTE_CLIPPED
Definition: d3dtypes.h:1256
#define D3DPROCESSVERTICES_TRANSFORM
Definition: d3dtypes.h:1055
DWORD D3DMATRIXHANDLE
Definition: d3dtypes.h:156
#define TRUE
Definition: types.h:120
#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 D3DDEB_CAPS
Definition: d3dcaps.h:143
#define D3DDEB_BUFSIZE
Definition: d3dcaps.h:142
#define D3DDEBCAPS_SYSTEMMEMORY
Definition: d3dcaps.h:145
unsigned int UINT
Definition: sysinfo.c:13
#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:6948
static void emit_set_rs(void **ptr, D3DRENDERSTATETYPE state, DWORD value)
Definition: d3drm.c:6915
static void emit_end(void **ptr)
Definition: d3drm.c:6972
static void set_execute_data(IDirect3DExecuteBuffer *execute_buffer, UINT vertex_count, UINT offset, UINT len)
Definition: d3drm.c:6886
static void emit_process_vertices(void **ptr, DWORD flags, WORD base_idx, DWORD vertex_count)
Definition: d3drm.c:6930
static void emit_set_ts(void **ptr, D3DTRANSFORMSTATETYPE state, DWORD value)
Definition: d3drm.c:6900
static const MAT2 mat
Definition: font.c:51
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 1480 of file d3drm.c.

1481{
1482 struct destroy_context *ctxt = arg;
1483 ok(ctxt->called == 1 || ctxt->called == 2, "got called counter %d\n", ctxt->called);
1484 ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1485 d3drm_corder[ctxt->called].callback = &destroy_callback;
1486 d3drm_corder[ctxt->called++].context = ctxt;
1487}
struct callback_order d3drm_corder[3]
IDirect3DRMObject * obj
Definition: d3drm.c:1469
void * arg
Definition: msvc.h:10

◆ destroy_callback1()

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

Definition at line 1489 of file d3drm.c.

1490{
1491 struct destroy_context *ctxt = (struct destroy_context*)arg;
1492 ok(ctxt->called == 0, "got called counter %d\n", ctxt->called);
1493 ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1494 d3drm_corder[ctxt->called].callback = &destroy_callback1;
1495 d3drm_corder[ctxt->called++].context = ctxt;
1496}
static void CDECL destroy_callback1(IDirect3DRMObject *obj, void *arg)
Definition: d3drm.c:1489

Referenced by destroy_callback1(), and test_destroy_callback().

◆ draw_quad2()

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

Definition at line 7227 of file d3drm.c.

7228{
7229 static D3DLVERTEX tquad[] =
7230 {
7231 {{-1.0f}, {-1.0f}, {0.0f}, 0, {0xffbada55}, {0}, {0.0f}, {0.0f}},
7232 {{-1.0f}, { 1.0f}, {0.0f}, 0, {0xffbada55}, {0}, {0.0f}, {1.0f}},
7233 {{ 1.0f}, {-1.0f}, {1.0f}, 0, {0xffbada55}, {0}, {1.0f}, {0.0f}},
7234 {{ 1.0f}, { 1.0f}, {1.0f}, 0, {0xffbada55}, {0}, {1.0f}, {1.0f}},
7235 };
7236 static D3DMATRIX mat =
7237 {
7238 1.0f, 0.0f, 0.0f, 0.0f,
7239 0.0f, 1.0f, 0.0f, 0.0f,
7240 0.0f, 0.0f, 1.0f, 0.0f,
7241 0.0f, 0.0f, 0.0f, 1.0f,
7242 };
7243 IDirect3DViewport2 *viewport2;
7244 HRESULT hr;
7245
7247 ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
7249 ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
7251 ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
7252
7253 hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport2, (void **)&viewport2);
7254 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport2 interface, hr %#lx.\n", hr);
7256 ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
7257 IDirect3DViewport2_Release(viewport2);
7258
7260 ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#lx.\n", hr);
7262 ok(SUCCEEDED(hr), "Failed to set the z function, hr %#lx.\n", hr);
7263
7265 ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
7267 ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
7269 ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
7270}
@ 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 6972 of file d3drm.c.

6973{
6974 D3DINSTRUCTION *inst = *ptr;
6975
6976 inst->bOpcode = D3DOP_EXIT;
6977 inst->bSize = 0;
6978 inst->wCount = 0;
6979
6980 *ptr = inst + 1;
6981}
@ 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 6930 of file d3drm.c.

6931{
6932 D3DINSTRUCTION *inst = *ptr;
6933 D3DPROCESSVERTICES *pv = (D3DPROCESSVERTICES *)(inst + 1);
6934
6936 inst->bSize = sizeof(*pv);
6937 inst->wCount = 1;
6938
6939 pv->dwFlags = flags;
6940 pv->wStart = base_idx;
6941 pv->wDest = 0;
6942 pv->dwCount = vertex_count;
6943 pv->dwReserved = 0;
6944
6945 *ptr = pv + 1;
6946}
@ D3DOP_PROCESSVERTICES
Definition: d3dtypes.h:652
GLbitfield flags
Definition: glext.h:7161
int vertex_count
Definition: d3drm.c:3528

Referenced by d3d_draw_quad1().

◆ emit_set_rs()

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

Definition at line 6915 of file d3drm.c.

6916{
6917 D3DINSTRUCTION *inst = *ptr;
6918 D3DSTATE *rs = (D3DSTATE *)(inst + 1);
6919
6920 inst->bOpcode = D3DOP_STATERENDER;
6921 inst->bSize = sizeof(*rs);
6922 inst->wCount = 1;
6923
6925 rs->dwArg[0] = value;
6926
6927 *ptr = rs + 1;
6928}
static int state
Definition: maze.c:121
@ D3DOP_STATERENDER
Definition: d3dtypes.h:651
DWORD dwArg[1]
Definition: d3dtypes.h:1030
D3DRENDERSTATETYPE drstRenderStateType
Definition: d3dtypes.h:1027

Referenced by d3d_draw_quad1().

◆ emit_set_ts()

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

Definition at line 6900 of file d3drm.c.

6901{
6902 D3DINSTRUCTION *inst = *ptr;
6903 D3DSTATE *ts = (D3DSTATE *)(inst + 1);
6904
6906 inst->bSize = sizeof(*ts);
6907 inst->wCount = 1;
6908
6910 ts->dwArg[0] = value;
6911
6912 *ptr = ts + 1;
6913}
@ D3DOP_STATETRANSFORM
Definition: d3dtypes.h:649
D3DTRANSFORMSTATETYPE dtstTransformStateType
Definition: d3dtypes.h:1025

Referenced by d3d_draw_quad1().

◆ emit_tquad()

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

Definition at line 6948 of file d3drm.c.

6949{
6950 D3DINSTRUCTION *inst = *ptr;
6951 D3DTRIANGLE *tri = (D3DTRIANGLE *)(inst + 1);
6952
6953 inst->bOpcode = D3DOP_TRIANGLE;
6954 inst->bSize = sizeof(*tri);
6955 inst->wCount = 2;
6956
6957 tri->v1 = base_idx;
6958 tri->v2 = base_idx + 1;
6959 tri->v3 = base_idx + 2;
6960 tri->wFlags = D3DTRIFLAG_START;
6961 ++tri;
6962
6963 tri->v1 = base_idx + 2;
6964 tri->v2 = base_idx + 1;
6965 tri->v3 = base_idx + 3;
6966 tri->wFlags = D3DTRIFLAG_ODD;
6967 ++tri;
6968
6969 *ptr = tri;
6970}
@ 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 69 of file d3drm.c.

73{
74 BOOL equal = compare_float(m[0][0], m11, ulps) && compare_float(m[0][1], m12, ulps)
75 && compare_float(m[0][2], m13, ulps) && compare_float(m[0][3], m14, ulps)
76 && compare_float(m[1][0], m21, ulps) && compare_float(m[1][1], m22, ulps)
77 && compare_float(m[1][2], m23, ulps) && compare_float(m[1][3], m24, ulps)
78 && compare_float(m[2][0], m31, ulps) && compare_float(m[2][1], m32, ulps)
79 && compare_float(m[2][2], m33, ulps) && compare_float(m[2][3], m34, ulps)
80 && compare_float(m[3][0], m41, ulps) && compare_float(m[3][1], m42, ulps)
81 && compare_float(m[3][2], m43, ulps) && compare_float(m[3][3], m44, ulps);
82
83 ok_(__FILE__, line)(equal,
84 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
85 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
86 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
87 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
88 m[0][0], m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3],
89 m[2][0], m[2][1], m[2][2], m[2][3], m[3][0], m[3][1], m[3][2], m[3][3],
90 m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
91}
#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:43
#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 94 of file d3drm.c.

95{
97 && compare_float(v->y, y, ulps)
98 && compare_float(v->z, z, ulps);
99
100 ok_(__FILE__, line)(equal, "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
101 v->x, v->y, v->z, x, y, z);
102}
const GLdouble * v
Definition: gl.h:2040
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 125 of file d3drm.c.

128{
130 {
131 {m11, m12, m13, m14},
132 {m21, m22, m23, m24},
133 {m31, m32, m33, m34},
134 {m41, m42, m43, m44},
135 };
136
138}
@ 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 6813 of file d3drm.c.

6814{
6815 RECT rect = { x, y, x + 1, y + 1 };
6816 DDSURFACEDESC surface_desc;
6818 HRESULT hr;
6819
6820 memset(&surface_desc, 0, sizeof(surface_desc));
6821 surface_desc.dwSize = sizeof(surface_desc);
6822
6823 hr = IDirectDrawSurface_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
6824 ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
6825 if (FAILED(hr))
6826 return 0xdeadbeef;
6827
6828 color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
6829
6830 hr = IDirectDrawSurface_Unlock(surface, NULL);
6831 ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
6832
6833 return color;
6834}
RECT rect
Definition: combotst.c:67
GLuint color
Definition: glext.h:6243
DWORD color
Definition: d3drm.c:3532
#define DDLOCK_READONLY
Definition: ddraw.h:626
#define DDLOCK_WAIT
Definition: ddraw.h:624

Referenced by test_viewport_clear1(), and test_viewport_clear2().

◆ matrix_sanitise()

static void matrix_sanitise ( D3DRMMATRIX4D  m)
static

Definition at line 147 of file d3drm.c.

148{
149 unsigned int i, j;
150
151 for (i = 0; i < 4; ++i)
152 {
153 for (j = 0; j < 4; ++j)
154 {
155 if (m[i][j] > -1e-7f && m[i][j] < 1e-7f)
156 m[i][j] = 0.0f;
157 }
158 }
159}

Referenced by test_frame_transform().

◆ object_load_callback()

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

Definition at line 3463 of file d3drm.c.

3464{
3465 ok(object != NULL, "Arg 1 should not be null\n");
3466 ok(IsEqualGUID(objectguid, refiids[nb_objects]), "Arg 2 is incorrect\n");
3467 ok(arg == (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg);
3468 nb_objects++;
3469}
static int nb_objects
Definition: d3drm.c:3454
static const GUID * refiids[]
Definition: d3drm.c:3455
#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 3493 of file d3drm.c.

3494{
3495 HRESULT hr;
3496 IDirect3DRMFrame *frame;
3497 IDirect3DRMVisualArray *array;
3498 IDirect3DRMVisual *visual;
3499 ULONG size;
3500 char name[128];
3501
3502 hr = IDirect3DRMObject_QueryInterface(object, &IID_IDirect3DRMFrame, (void**)&frame);
3503 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3504
3506 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3507
3509 ok(size == 1, "Wrong size %lu returned, expected 1\n", size);
3510
3512 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3513
3514 hr = IDirect3DRMVisual_QueryInterface(visual, &IID_IDirect3DRMMeshBuilder, (void**)&mesh_builder);
3515 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3516
3517 size = sizeof(name);
3519 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3520 ok(!strcmp(name, "mesh1"), "Wrong name %s, expected mesh1\n", name);
3521
3525}
#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
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
IDirect3DRMMeshBuilder * mesh_builder
Definition: d3drm.c:3491
Definition: undname.c:54
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 6886 of file d3drm.c.

6887{
6888 D3DEXECUTEDATA exec_data;
6889 HRESULT hr;
6890
6891 memset(&exec_data, 0, sizeof(exec_data));
6892 exec_data.dwSize = sizeof(exec_data);
6893 exec_data.dwVertexCount = vertex_count;
6894 exec_data.dwInstructionOffset = offset;
6895 exec_data.dwInstructionLength = len;
6896 hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
6897 ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
6898}
#define IDirect3DExecuteBuffer_SetExecuteData(p, a)
Definition: d3d.h:909
GLintptr offset
Definition: glext.h:5920
GLenum GLsizei len
Definition: glext.h:6722
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 140 of file d3drm.c.

141{
142 v->x = x;
143 v->y = y;
144 v->z = z;
145}

Referenced by test_frame_transform().

◆ START_TEST()

START_TEST ( d3drm  )

Definition at line 8233 of file d3drm.c.

8234{
8237 test_Mesh();
8238 test_Face();
8239 test_Frame();
8240 test_Device();
8241 test_object();
8242 test_Viewport();
8243 test_Light();
8245 test_Texture();
8249 test_d3drm_qi();
8250 test_frame_qi();
8272 test_wrap();
8273 test_wrap_qi();
8274}
static void test_create_device_from_clipper1(void)
Definition: d3drm.c:4024
static void test_texture_qi(void)
Definition: d3drm.c:6542
static void test_animation_qi(void)
Definition: d3drm.c:8022
static void test_Mesh(void)
Definition: d3drm.c:817
static void test_Material2(void)
Definition: d3drm.c:2632
static void test_Texture(void)
Definition: d3drm.c:2700
static void test_d3drm_qi(void)
Definition: d3drm.c:3677
static void test_create_device_2(void)
Definition: d3drm.c:6118
static void test_load_texture(void)
Definition: d3drm.c:6357
static void test_MeshBuilder3(void)
Definition: d3drm.c:718
static void test_wrap_qi(void)
Definition: d3drm.c:8145
static void test_create_device_3(void)
Definition: d3drm.c:6140
static void test_create_device_from_d3d3(void)
Definition: d3drm.c:5820
static void test_create_device_from_surface3(void)
Definition: d3drm.c:4908
static void test_animation(void)
Definition: d3drm.c:7675
static void test_MeshBuilder(void)
Definition: d3drm.c:434
static void test_create_device_from_clipper2(void)
Definition: d3drm.c:4194
static void test_Device(void)
Definition: d3drm.c:3143
static void test_create_device_from_d3d2(void)
Definition: d3drm.c:5538
static void test_viewport_clear2(void)
Definition: d3drm.c:7272
static void test_device_qi(void)
Definition: d3drm.c:3878
static void test_frame_transform(void)
Definition: d3drm.c:3192
static void test_viewport_qi(void)
Definition: d3drm.c:6667
static void test_Light(void)
Definition: d3drm.c:2568
static void test_create_device_1(void)
Definition: d3drm.c:6100
static void test_frame_qi(void)
Definition: d3drm.c:3761
static void test_create_device_from_surface1(void)
Definition: d3drm.c:4555
static void test_create_device_from_surface2(void)
Definition: d3drm.c:4726
static void test_Viewport(void)
Definition: d3drm.c:1742
static void test_object(void)
Definition: d3drm.c:1600
static void test_frame_mesh_materials(void)
Definition: d3drm.c:3542
static void test_create_device_from_d3d1(void)
Definition: d3drm.c:5204
static void test_create_texture_from_surface(void)
Definition: d3drm.c:7509
static void test_d3drm_load(void)
Definition: d3drm.c:3471
static void test_viewport_clear1(void)
Definition: d3drm.c:7062
static void test_create_device_from_clipper3(void)
Definition: d3drm.c:4372
static void test_Face(void)
Definition: d3drm.c:846
static void test_wrap(void)
Definition: d3drm.c:8127
static void test_Frame(void)
Definition: d3drm.c:1074

◆ surface_callback()

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

Definition at line 4010 of file d3drm.c.

4011{
4012 IDirectDrawSurface **primary = context;
4013
4014 if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
4015 {
4016 *primary = surface;
4017 return DDENUMRET_CANCEL;
4018 }
4019 IDirectDrawSurface_Release(surface);
4020
4021 return DDENUMRET_OK;
4022}
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
#define DDENUMRET_OK
Definition: ddraw.h:191
#define DDSCAPS_PRIMARYSURFACE
Definition: ddraw.h:260
#define DDENUMRET_CANCEL
Definition: ddraw.h:190
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 7675 of file d3drm.c.

7676{
7677 IDirect3DRMAnimation2 *animation2;
7678 IDirect3DRMAnimation *animation;
7680 IDirect3DRMObject *obj, *obj2;
7682 IDirect3DRMFrame3 *frame3;
7683 IDirect3DRMFrame *frame;
7685 IDirect3DRM *d3drm1;
7687 DWORD count, i;
7688 HRESULT hr;
7689 D3DVECTOR v;
7690
7691 hr = Direct3DRMCreate(&d3drm1);
7692 ok(SUCCEEDED(hr), "Failed to create IDirect3DRM instance, hr %#lx.\n", hr);
7693
7695 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7696
7697 CHECK_REFCOUNT(d3drm1, 1);
7698 hr = IDirect3DRM_CreateAnimation(d3drm1, &animation);
7699 ok(SUCCEEDED(hr), "Failed to create animation hr %#lx.\n", hr);
7700 CHECK_REFCOUNT(d3drm1, 2);
7701
7702 test_class_name((IDirect3DRMObject *)animation, "Animation");
7703
7704 hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IDirect3DRMAnimation2, (void **)&animation2);
7705 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMAnimation2, hr %#lx.\n", hr);
7706 ok(animation != (void *)animation2, "Expected different interface pointer.\n");
7707
7708 hr = IDirect3DRMAnimation_QueryInterface(animation, &IID_IDirect3DRMObject, (void **)&obj);
7709 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr %#lx.\n", hr);
7710
7711 hr = IDirect3DRMAnimation2_QueryInterface(animation2, &IID_IDirect3DRMObject, (void **)&obj2);
7712 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr %#lx.\n", hr);
7713
7714 ok(obj == obj2 && obj == (IDirect3DRMObject *)animation, "Unexpected object pointer.\n");
7715
7718
7719 /* Set animated frame, get it back. */
7720 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame);
7721 ok(SUCCEEDED(hr), "Failed to create a frame, hr %#lx.\n", hr);
7722
7724 ok(SUCCEEDED(hr), "Failed to reset frame, hr %#lx.\n", hr);
7725
7726 CHECK_REFCOUNT(frame, 1);
7727 hr = IDirect3DRMAnimation_SetFrame(animation, frame);
7728 ok(SUCCEEDED(hr), "Failed to set a frame, hr %#lx.\n", hr);
7729 CHECK_REFCOUNT(frame, 1);
7730
7731 hr = IDirect3DRMAnimation2_GetFrame(animation2, NULL);
7732 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7733
7734 hr = IDirect3DRMAnimation2_GetFrame(animation2, &frame3);
7735 ok(SUCCEEDED(hr), "Failed to get the frame, hr %#lx.\n", hr);
7736 ok(frame3 != (void *)frame, "Unexpected interface pointer.\n");
7737 CHECK_REFCOUNT(frame, 2);
7738
7740
7742 ok(SUCCEEDED(hr), "Failed to reset frame, hr %#lx.\n", hr);
7743
7744 hr = IDirect3DRMFrame_QueryInterface(frame, &IID_IDirect3DRMFrame3, (void **)&frame3);
7745 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMFrame3, hr %#lx.\n", hr);
7746
7747 CHECK_REFCOUNT(frame3, 2);
7748 hr = IDirect3DRMAnimation2_SetFrame(animation2, frame3);
7749 ok(SUCCEEDED(hr), "Failed to set a frame, hr %#lx.\n", hr);
7750 CHECK_REFCOUNT(frame3, 2);
7751
7754
7755 /* Animation options. */
7758 "Unexpected default options %#lx.\n", options);
7759
7760 /* Undefined mask value */
7761 hr = IDirect3DRMAnimation_SetOptions(animation, 0xf0000000);
7762 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7763
7766 "Unexpected default options %#lx.\n", options);
7767
7768 /* Ambiguous mask */
7770 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7771
7773 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7774
7776 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7777
7780 "Unexpected default options %#lx.\n", options);
7781
7782 /* Mask contains undefined bits together with valid one. */
7783 hr = IDirect3DRMAnimation_SetOptions(animation, 0xf0000000 | D3DRMANIMATION_OPEN);
7784 ok(SUCCEEDED(hr), "Failed to set animation options, hr %#lx.\n", hr);
7785
7787 ok(options == (0xf0000000 | D3DRMANIMATION_OPEN), "Unexpected animation options %#lx.\n", options);
7788
7790 ok(SUCCEEDED(hr), "Failed to set animation options, hr %#lx.\n", hr);
7791
7793 ok(options == D3DRMANIMATION_SCALEANDROTATION, "Unexpected options %#lx.\n", options);
7794
7796 ok(SUCCEEDED(hr), "Failed to set animation options, hr %#lx.\n", hr);
7797
7799 ok(options == D3DRMANIMATION_OPEN, "Unexpected options %#lx.\n", options);
7800
7801 hr = IDirect3DRMAnimation_SetOptions(animation, 0);
7802 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7803
7805 ok(options == D3DRMANIMATION_OPEN, "Unexpected options %#lx.\n", options);
7806
7807 /* Key management. */
7808 hr = IDirect3DRMAnimation_AddPositionKey(animation, 0.0f, 1.0f, 0.0f, 0.0f);
7809 ok(SUCCEEDED(hr), "Failed to add position key, hr %#lx.\n", hr);
7810
7811 hr = IDirect3DRMAnimation_AddScaleKey(animation, 0.0f, 1.0f, 2.0f, 1.0f);
7812 ok(SUCCEEDED(hr), "Failed to add scale key, hr %#lx.\n", hr);
7813
7814 hr = IDirect3DRMAnimation_AddPositionKey(animation, 0.0f, 2.0f, 0.0f, 0.0f);
7815 ok(SUCCEEDED(hr), "Failed to add position key, hr %#lx.\n", hr);
7816
7817 hr = IDirect3DRMAnimation_AddPositionKey(animation, 99.0f, 3.0f, 1.0f, 0.0f);
7818 ok(SUCCEEDED(hr), "Failed to add position key, hr %#lx.\n", hr);
7819
7820 hr = IDirect3DRMAnimation_AddPositionKey(animation, 80.0f, 4.0f, 1.0f, 0.0f);
7821 ok(SUCCEEDED(hr), "Failed to add position key, hr %#lx.\n", hr);
7822
7823 v.x = 1.0f;
7824 v.y = 0.0f;
7825 v.z = 0.0f;
7827
7828 /* NULL quaternion pointer leads to a crash on Windows. */
7829 hr = IDirect3DRMAnimation_AddRotateKey(animation, 0.0f, &q);
7830 ok(SUCCEEDED(hr), "Failed to add rotation key, hr %#lx.\n", hr);
7831
7832 count = 0;
7833 memset(keys, 0, sizeof(keys));
7834 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 99.0f, &count, keys);
7835 ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#lx.\n", hr);
7836 ok(count == 6, "Unexpected key count %lu.\n", count);
7837
7838 ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %lu.\n", keys[0].dwKeyType);
7839 ok(keys[1].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[1].dwKeyType);
7840 ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[2].dwKeyType);
7841 ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[3].dwKeyType);
7842 ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[4].dwKeyType);
7843 ok(keys[5].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %lu.\n", keys[5].dwKeyType);
7844
7845 /* Relative order, keys are returned sorted by time. */
7846 ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7847 ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7848 ok(keys[3].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7849 ok(keys[4].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7850
7851 /* For keys with same time, order they were added in is kept. */
7852 ok(keys[1].dvPositionKey.x == 1.0f, "Unexpected key position x %.8e.\n", keys[1].dvPositionKey.x);
7853 ok(keys[2].dvPositionKey.x == 2.0f, "Unexpected key position x %.8e.\n", keys[2].dvPositionKey.x);
7854 ok(keys[3].dvPositionKey.x == 4.0f, "Unexpected key position x %.8e.\n", keys[3].dvPositionKey.x);
7855 ok(keys[4].dvPositionKey.x == 3.0f, "Unexpected key position x %.8e.\n", keys[4].dvPositionKey.x);
7856
7857 for (i = 0; i < count; i++)
7858 {
7859 winetest_push_context("%lu", i);
7860
7861 ok(keys[i].dwSize == sizeof(*keys), "Unexpected dwSize value %lu.\n", keys[i].dwSize);
7862
7863 todo_wine
7864 {
7865 switch (keys[i].dwKeyType)
7866 {
7868 ok((keys[i].dwID & 0xf0000000) == 0x40000000, "Unexpected id mask %#lx.\n", keys[i].dwID);
7869 break;
7871 ok((keys[i].dwID & 0xf0000000) == 0x80000000, "Unexpected id mask %#lx.\n", keys[i].dwID);
7872 break;
7874 ok((keys[i].dwID & 0xf0000000) == 0xc0000000, "Unexpected id mask %#lx.\n", keys[i].dwID);
7875 break;
7876 default:
7877 ok(0, "Unknown key type %ld.\n", keys[i].dwKeyType);
7878 }
7879 }
7880
7882 }
7883
7884 /* No keys in this range. */
7885 count = 10;
7886 hr = IDirect3DRMAnimation2_GetKeys(animation2, 100.0f, 200.0f, &count, NULL);
7887 ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#lx.\n", hr);
7888 ok(count == 0, "Unexpected key count %lu.\n", count);
7889
7890 count = 10;
7891 hr = IDirect3DRMAnimation2_GetKeys(animation2, 100.0f, 200.0f, &count, keys);
7892 ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#lx.\n", hr);
7893 ok(count == 0, "Unexpected key count %lu.\n", count);
7894
7895 count = 10;
7896 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 0.0f, &count, NULL);
7897 ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#lx.\n", hr);
7898 ok(count == 4, "Unexpected key count %lu.\n", count);
7899
7900 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, NULL, NULL);
7901 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7902
7903 /* Time is 0-based. */
7904 hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, -50.0f, NULL, NULL);
7905 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
7906
7907 count = 10;
7908 hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, -50.0f, &count, NULL);
7909 ok(hr == D3DRMERR_NOSUCHKEY, "Unexpected hr %#lx.\n", hr);
7910 ok(count == 0, "Unexpected key count %lu.\n", count);
7911
7912 count = 10;
7913 hr = IDirect3DRMAnimation2_GetKeys(animation2, -100.0f, 100.0f, &count, NULL);
7914 ok(SUCCEEDED(hr), "Failed to get animation keys, hr %#lx.\n", hr);
7915 ok(count == 6, "Unexpected key count %lu.\n", count);
7916
7917 /* AddKey() tests. */
7918 hr = IDirect3DRMAnimation2_AddKey(animation2, NULL);
7919 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7920
7921 memset(&key, 0, sizeof(key));
7922 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7923 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7924 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7925
7926 memset(&key, 0, sizeof(key));
7927 key.dwSize = sizeof(key) - 1;
7928 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7929 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7930 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7931
7932 memset(&key, 0, sizeof(key));
7933 key.dwSize = sizeof(key) + 1;
7934 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7935 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7936 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7937
7938 memset(&key, 0, sizeof(key));
7939 key.dwSize = sizeof(key);
7940 key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
7941 key.dvPositionKey.x = 8.0f;
7942 hr = IDirect3DRMAnimation2_AddKey(animation2, &key);
7943 ok(SUCCEEDED(hr), "Failed to add key, hr %#lx.\n", hr);
7944
7945 /* Delete tests. */
7946 hr = IDirect3DRMAnimation_AddRotateKey(animation, 0.0f, &q);
7947 ok(SUCCEEDED(hr), "Failed to add rotation key, hr %#lx.\n", hr);
7948
7949 hr = IDirect3DRMAnimation_AddScaleKey(animation, 0.0f, 1.0f, 2.0f, 1.0f);
7950 ok(SUCCEEDED(hr), "Failed to add scale key, hr %#lx.\n", hr);
7951
7952 count = 0;
7953 memset(keys, 0, sizeof(keys));
7954 hr = IDirect3DRMAnimation2_GetKeys(animation2, -1000.0f, 1000.0f, &count, keys);
7955 ok(SUCCEEDED(hr), "Failed to get key count, hr %#lx.\n", hr);
7956 ok(count == 9, "Unexpected key count %lu.\n", count);
7957
7958 ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %lu.\n", keys[0].dwKeyType);
7959 ok(keys[1].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %lu.\n", keys[1].dwKeyType);
7960 ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[2].dwKeyType);
7961 ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[3].dwKeyType);
7962 ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[4].dwKeyType);
7963 ok(keys[5].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[5].dwKeyType);
7964 ok(keys[6].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[6].dwKeyType);
7965 ok(keys[7].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %lu.\n", keys[7].dwKeyType);
7966 ok(keys[8].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %lu.\n", keys[8].dwKeyType);
7967
7968 ok(keys[0].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[0].dvTime);
7969 ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
7970 ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
7971 ok(keys[3].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
7972 ok(keys[4].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
7973 ok(keys[5].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[5].dvTime);
7974 ok(keys[6].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[6].dvTime);
7975 ok(keys[7].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[7].dvTime);
7976 ok(keys[8].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[8].dvTime);
7977
7978 hr = IDirect3DRMAnimation_DeleteKey(animation, -100.0f);
7979 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#lx.\n", hr);
7980
7981 hr = IDirect3DRMAnimation_DeleteKey(animation, 100.0f);
7982 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#lx.\n", hr);
7983
7984 /* Only first Position keys are not removed. */
7985 hr = IDirect3DRMAnimation_DeleteKey(animation, 0.0f);
7986 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#lx.\n", hr);
7987
7988 count = 0;
7989 memset(keys, 0, sizeof(keys));
7990 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, &count, keys);
7991 ok(SUCCEEDED(hr), "Failed to get key count, hr %#lx.\n", hr);
7992 ok(count == 6, "Unexpected key count %lu.\n", count);
7993
7994 ok(keys[0].dwKeyType == D3DRMANIMATION_ROTATEKEY, "Unexpected key type %lu.\n", keys[0].dwKeyType);
7995 ok(keys[1].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[1].dwKeyType);
7996 ok(keys[2].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[2].dwKeyType);
7997 ok(keys[3].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[3].dwKeyType);
7998 ok(keys[4].dwKeyType == D3DRMANIMATION_POSITIONKEY, "Unexpected key type %lu.\n", keys[4].dwKeyType);
7999 ok(keys[5].dwKeyType == D3DRMANIMATION_SCALEKEY, "Unexpected key type %lu.\n", keys[5].dwKeyType);
8000
8001 ok(keys[0].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[0].dvTime);
8002 ok(keys[1].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[1].dvTime);
8003 ok(keys[2].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[2].dvTime);
8004 ok(keys[3].dvTime == 80.0f, "Unexpected key time %.8e.\n", keys[3].dvTime);
8005 ok(keys[4].dvTime == 99.0f, "Unexpected key time %.8e.\n", keys[4].dvTime);
8006 ok(keys[5].dvTime == 0.0f, "Unexpected key time %.8e.\n", keys[5].dvTime);
8007
8008 hr = IDirect3DRMAnimation_DeleteKey(animation, 0.0f);
8009 ok(SUCCEEDED(hr), "Failed to delete keys, hr %#lx.\n", hr);
8010
8011 count = 0;
8012 hr = IDirect3DRMAnimation2_GetKeys(animation2, 0.0f, 100.0f, &count, NULL);
8013 ok(SUCCEEDED(hr), "Failed to get key count, hr %#lx.\n", hr);
8014 ok(count == 3, "Unexpected key count %lu.\n", count);
8015
8018
8019 IDirect3DRM_Release(d3drm1);
8020}
#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 UINT * keys
Definition: locale.c:418
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
#define todo_wine
Definition: minitest.h:80
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:171
Definition: copy.c:22

Referenced by START_TEST().

◆ test_animation_qi()

static void test_animation_qi ( void  )
static

Definition at line 8022 of file d3drm.c.

8023{
8024 static const struct qi_test tests[] =
8025 {
8026 { &IID_IDirect3DRMAnimation2, &IID_IUnknown, &IID_IDirect3DRMAnimation2, S_OK },
8027 { &IID_IDirect3DRMAnimation, &IID_IUnknown, &IID_IDirect3DRMAnimation, S_OK },
8028 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8029 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8030 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMAnimation, S_OK },
8031 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8032 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8033 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8034 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8035 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8036 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8037 { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8038 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8039 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8040 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8041 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8042 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8043 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8044 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8045 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8046 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8047 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8048 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8049 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8050 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8051 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8052 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8053 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8054 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8055 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8056 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8057 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8058 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8059 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8060 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8061 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8062 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8063 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8064 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8065 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8066 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8067 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8068 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8069 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8070 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8071 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8072 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8073 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8074 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8075 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8076 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8077 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8078 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8079 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8080 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8081 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8082 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8083 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8084 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8085 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8086 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8087 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8089 };
8090 IDirect3DRMAnimation2 *animation2;
8091 IDirect3DRMAnimation *animation;
8092 IDirect3DRM3 *d3drm3;
8093 IDirect3DRM *d3drm1;
8095 HRESULT hr;
8096
8097 hr = Direct3DRMCreate(&d3drm1);
8098 ok(SUCCEEDED(hr), "Failed to create d3drm instance, hr %#lx.\n", hr);
8099
8100 hr = IDirect3DRM_CreateAnimation(d3drm1, &animation);
8101 ok(SUCCEEDED(hr), "Failed to create animation hr %#lx.\n", hr);
8102
8104 ok(SUCCEEDED(hr), "Failed to get IUnknown from animation, hr %#lx.\n", hr);
8106
8107 test_qi("animation_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
8108 IUnknown_Release(unknown);
8109
8110 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
8111 ok(SUCCEEDED(hr), "Failed to get IDirect3DRM3, hr %#lx.\n", hr);
8112
8113 hr = IDirect3DRM3_CreateAnimation(d3drm3, &animation2);
8114 ok(SUCCEEDED(hr), "Failed to create animation hr %#lx.\n", hr);
8115
8117 ok(SUCCEEDED(hr), "Failed to get IUnknown from animation, hr %#lx.\n", hr);
8119
8120 test_qi("animation2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
8121 IUnknown_Release(unknown);
8122
8123 IDirect3DRM3_Release(d3drm3);
8124 IDirect3DRM_Release(d3drm1);
8125}
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:1674
#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:3628
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772

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

6242{
6243 const unsigned char *data = img->buffer1;
6244 unsigned int i, j;
6245
6246 ok(img->width == w, "Test %u: Got unexpected image width %u, expected %u.\n", test_idx, img->width, w);
6247 ok(img->height == h, "Test %u: Got unexpected image height %u, expected %u.\n", test_idx, img->height, h);
6248 ok(img->aspectx == 1, "Test %u: Got unexpected image aspectx %u.\n", test_idx, img->aspectx);
6249 ok(img->aspecty == 1, "Test %u: Got unexpected image aspecty %u.\n", test_idx, img->aspecty);
6250 ok(!img->buffer2, "Test %u: Got unexpected image buffer2 %p.\n", test_idx, img->buffer2);
6251
6252 /* The image is palettized if the total number of colors used is <= 256. */
6253 if (w * h > 256 && !palettized)
6254 {
6255 /* D3drm aligns the 24bpp texture to 4 bytes in the buffer, with one
6256 * byte padding from 24bpp texture. */
6257 ok(img->depth == 32, "Test %u: Got unexpected image depth %u.\n", test_idx, img->depth);
6258 ok(img->rgb == TRUE, "Test %u: Got unexpected image rgb %#x.\n", test_idx, img->rgb);
6259 ok(img->bytes_per_line == w * 4, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6260 test_idx, img->bytes_per_line, w * 4);
6261 ok(img->red_mask == 0xff0000, "Test %u: Got unexpected image red mask %#lx.\n", test_idx, img->red_mask);
6262 ok(img->green_mask == 0x00ff00, "Test %u: Got unexpected image green mask %#lx.\n", test_idx, img->green_mask);
6263 ok(img->blue_mask == 0x0000ff, "Test %u: Got unexpected image blue mask %#lx.\n", test_idx, img->blue_mask);
6264 ok(!img->alpha_mask, "Test %u: Got unexpected image alpha mask %#lx.\n", test_idx, img->alpha_mask);
6265 ok(!img->palette_size, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
6266 ok(!img->palette, "Test %u: Got unexpected image palette %p.\n", test_idx, img->palette);
6267 for (i = 0; i < h; ++i)
6268 {
6269 for (j = 0; j < w; ++j)
6270 {
6271 const unsigned char *ptr = &data[i * img->bytes_per_line + j * 4];
6272 unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
6273
6274 if (ptr[0] != idx % MOD_B || ptr[1] != idx % MOD_G || ptr[2] != idx % MOD_R || ptr[3] != 0xff)
6275 {
6276 ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
6277 "expected 0x%02x%02x%02x%02x.\n", test_idx, ptr[0], ptr[1], ptr[2], ptr[3],
6278 j, i, idx % MOD_B, idx % MOD_G, idx % MOD_R, 0xff);
6279 return;
6280 }
6281 }
6282 }
6283 return;
6284 }
6285
6286 ok(img->depth == 8, "Test %u: Got unexpected image depth %u.\n", test_idx, img->depth);
6287 ok(!img->rgb, "Test %u: Got unexpected image rgb %#x.\n", test_idx, img->rgb);
6288 ok(img->red_mask == 0xff, "Test %u: Got unexpected image red mask %#lx.\n", test_idx, img->red_mask);
6289 ok(img->green_mask == 0xff, "Test %u: Got unexpected image green mask %#lx.\n", test_idx, img->green_mask);
6290 ok(img->blue_mask == 0xff, "Test %u: Got unexpected image blue mask %#lx.\n", test_idx, img->blue_mask);
6291 ok(!img->alpha_mask, "Test %u: Got unexpected image alpha mask %#lx.\n", test_idx, img->alpha_mask);
6292 ok(!!img->palette, "Test %u: Got unexpected image palette %p.\n", test_idx, img->palette);
6293 if (!palettized)
6294 {
6295 /* In this case, bytes_per_line is aligned to the next multiple of
6296 * 4 from width. */
6297 ok(img->bytes_per_line == ((w + 3) & ~3), "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6298 test_idx, img->bytes_per_line, (w + 3) & ~3);
6299 ok(img->palette_size == w * h, "Test %u: Got unexpected palette size %u, expected %u.\n",
6300 test_idx, img->palette_size, w * h);
6301 for (i = 0; i < img->palette_size; ++i)
6302 {
6303 unsigned int idx = upside_down ? (h - 1) * w - i + (i % w) * 2 : i;
6304 ok(img->palette[i].red == idx % MOD_R
6305 && img->palette[i].green == idx % MOD_G && img->palette[i].blue == idx % MOD_B,
6306 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
6307 test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
6308 ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
6309 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
6310 test_idx, i, img->palette[i].flags);
6311 }
6312 for (i = 0; i < h; ++i)
6313 {
6314 for (j = 0; j < w; ++j)
6315 {
6316 if (data[i * img->bytes_per_line + j] != i * w + j)
6317 {
6318 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
6319 test_idx, data[i * img->bytes_per_line + j], j, i, i * w + j);
6320 return;
6321 }
6322 }
6323 }
6324 return;
6325 }
6326
6327 /* bytes_per_line is not always aligned by d3drm depending on the
6328 * format. */
6329 ok(img->bytes_per_line == w, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6330 test_idx, img->bytes_per_line, w);
6331 ok(img->palette_size == 256, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
6332 for (i = 0; i < 256; ++i)
6333 {
6334 ok(img->palette[i].red == i % MOD_R
6335 && img->palette[i].green == i % MOD_G && img->palette[i].blue == i % MOD_B,
6336 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
6337 test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
6338 ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
6339 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
6340 test_idx, i, img->palette[i].flags);
6341 }
6342 for (i = 0; i < h; ++i)
6343 {
6344 for (j = 0; j < w; ++j)
6345 {
6346 unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
6347 if (data[i * img->bytes_per_line + j] != idx % 256)
6348 {
6349 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
6350 test_idx, data[i * img->bytes_per_line + j], j, i, idx % 256);
6351 return;
6352 }
6353 }
6354 }
6355}
@ D3DRMPALETTE_READONLY
Definition: d3drmdef.h:135
unsigned int idx
Definition: utils.c:40
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 172 of file d3drm.c.

173{
174 char cname[64] = {0};
175 DWORD size, size2;
176 HRESULT hr;
177
178 hr = IDirect3DRMObject_GetClassName(object, NULL, cname);
179 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
181 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
182
183 size = 0;
185 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname size, hr %#lx.\n", hr);
186 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %lu.\n", size);
187
188 size = size2 = !!*name;
189 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
190 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
191 ok_(__FILE__, line)(size == size2, "Got size %lu.\n", size);
192
193 size = sizeof(cname);
194 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
195 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#lx.\n", hr);
196 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %lu.\n", size);
197 ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
198
199 size = strlen(name) + 1;
200 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
201 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#lx.\n", hr);
202 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %lu.\n", size);
203 ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
204
205 size = strlen(name);
206 strcpy(cname, "XXX");
207 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
208 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
209 ok_(__FILE__, line)(size == strlen(name), "Wrong classname size: %lu.\n", size);
210 ok_(__FILE__, line)(!strcmp(cname, "XXX"), "Expected unchanged buffer, but got \"%s\".\n", cname);
211}
#define IDirect3DRMViewport_GetClassName(p, a, b)
Definition: d3drmobj.h:856
#define IDirect3DRMObject_GetClassName(p, a, b)
Definition: d3drmobj.h:229
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
strcpy
Definition: string.h:131

◆ test_create_device_1()

static void test_create_device_1 ( void  )
static

Definition at line 6100 of file d3drm.c.

6101{
6102 IDirect3DRM *d3drm = NULL;
6103 IDirect3DRMDevice *device = (IDirect3DRMDevice *)0xdeadbeef;
6104 HRESULT hr;
6105
6107 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
6108
6109 hr = IDirect3DRM_CreateDevice(d3drm, 640, 480, &device);
6110 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == D3DRMERR_BADDEVICE, got hr %#lx.\n", hr);
6111 ok(device == NULL, "Expected device returned == NULL, got %p.\n", device);
6112 hr = IDirect3DRM_CreateDevice(d3drm, 640, 480, NULL);
6113 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
6114
6116}
#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 6118 of file d3drm.c.

6119{
6120 IDirect3DRM *d3drm = NULL;
6121 IDirect3DRM2 *d3drm2 = NULL;
6122 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
6123 HRESULT hr;
6124
6126 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
6127 hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM2, (void **)&d3drm2);
6128 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
6129
6130 hr = IDirect3DRM2_CreateDevice(d3drm2, 640, 480, &device2);
6131 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == D3DRMERR_BADDEVICE, got %#lx.\n", hr);
6132 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
6133 hr = IDirect3DRM2_CreateDevice(d3drm2, 640, 480, NULL);
6134 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
6135
6136 IDirect3DRM2_Release(d3drm2);
6138}
#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 6140 of file d3drm.c.

6141{
6142 IDirect3DRM *d3drm = NULL;
6143 IDirect3DRM3 *d3drm3 = NULL;
6144 IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
6145 HRESULT hr;
6146
6148 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
6149 hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3);
6150 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
6151
6152 hr = IDirect3DRM3_CreateDevice(d3drm3, 640, 480, &device3);
6153 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == D3DRMERR_BADDEVICE, got %#lx.\n", hr);
6154 ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
6155 hr = IDirect3DRM3_CreateDevice(d3drm3, 640, 480, NULL);
6156 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
6157
6158 IDirect3DRM3_Release(d3drm3);
6160}
#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 4024 of file d3drm.c.

4025{
4026 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4027 IDirect3DRM *d3drm1 = NULL;
4028 IDirectDraw *ddraw = NULL;
4030 IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
4031 IDirect3DDevice *d3ddevice1 = NULL;
4032 IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
4033 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
4034 IDirectDrawSurface7 *surface7 = NULL;
4035 DDSURFACEDESC desc, surface_desc;
4036 DWORD expected_flags, ret_val;
4037 HWND window;
4038 GUID driver = IID_IDirect3DRGBDevice;
4039 HRESULT hr;
4040 ULONG ref1, ref2, cref1, cref2;
4041 RECT rc;
4042
4044 GetClientRect(window, &rc);
4045 hr = DirectDrawCreateClipper(0, &clipper, NULL);
4046 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr);
4047 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
4048 ok(hr == DD_OK, "Cannot set HWnd to Clipper, hr %#lx.\n", hr);
4049
4050 hr = Direct3DRMCreate(&d3drm1);
4051 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
4052 ref1 = get_refcount((IUnknown *)d3drm1);
4053 cref1 = get_refcount((IUnknown *)clipper);
4054
4055 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 0, 0, &device1);
4056 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
4057 ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
4058
4059 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4060 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, NULL, &driver, 300, 200, &device1);
4061 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
4062
4063 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 300, 200, NULL);
4064 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
4065
4066 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 300, 200, &device1);
4067 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr);
4068 ref2 = get_refcount((IUnknown *)d3drm1);
4069 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
4070 cref2 = get_refcount((IUnknown *)clipper);
4071 ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %lu , cref2 = %lu.\n", cref1, cref2);
4072 ret_val = IDirect3DRMDevice_GetWidth(device1);
4073 ok(ret_val == 300, "Expected device width = 300, got %lu.\n", ret_val);
4074 ret_val = IDirect3DRMDevice_GetHeight(device1);
4075 ok(ret_val == 200, "Expected device height == 200, got %lu.\n", ret_val);
4076
4077 /* Fetch immediate mode device in order to access render target */
4078 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
4079 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
4080
4081 hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
4082 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4083
4084 hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
4085 ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got hr %#lx.\n", hr);
4086
4087 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4088 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
4089 ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface, hr %#lx.\n", hr);
4090 IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
4091 hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
4092 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4093 IUnknown_Release(unknown);
4094 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4095 NULL, &d3drm_primary, surface_callback);
4096 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
4097 ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
4098 hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
4099 ok(hr == DD_OK, "Cannot get attached clipper from primary surface, hr %#lx.\n", hr);
4100 ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
4101
4102 IDirectDrawClipper_Release(d3drm_clipper);
4103 IDirectDrawSurface_Release(d3drm_primary);
4104 IDirectDrawSurface7_Release(surface7);
4105 IDirectDraw_Release(ddraw);
4106
4107 /* Check properties of render target and depth surface */
4108 surface_desc.dwSize = sizeof(surface_desc);
4109 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4110 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
4111
4112 ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4113 surface_desc.dwWidth, surface_desc.dwHeight);
4114 ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
4115 "Unexpected caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
4117 ok(surface_desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, surface_desc.dwFlags);
4118
4120 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4121 desc.dwSize = sizeof(desc);
4122 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4123 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4124 ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %lu bpp, got %lu bpp.\n",
4125 surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
4126
4127 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4128 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4129
4130 desc.dwSize = sizeof(desc);
4131 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4132 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
4133
4134 ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4135 desc.dwWidth, desc.dwHeight);
4136 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
4138 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
4139 ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %lu.\n", desc.dwZBufferBitDepth);
4140 ok(!desc.ddpfPixelFormat.dwStencilBitMask, "Unexpected stencil mask %#lx.\n", desc.ddpfPixelFormat.dwStencilBitMask);
4141
4142 /* Release old objects and check refcount of device and clipper */
4143 IDirectDrawSurface_Release(ds);
4144 ds = NULL;
4145 IDirectDrawSurface_Release(surface);
4146 surface = NULL;
4147 IDirect3DDevice_Release(d3ddevice1);
4148 d3ddevice1 = NULL;
4150 ref2 = get_refcount((IUnknown *)d3drm1);
4151 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
4152 cref2 = get_refcount((IUnknown *)clipper);
4153 ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %lu, cref2 = %lu.\n", cref1, cref2);
4154
4155 /* Test if render target format follows the screen format */
4156 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4157 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4158 hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
4159 ok(hr == DD_OK, "Cannot set display mode to 16bpp, hr %#lx.\n", hr);
4160
4161 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4162 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4163 ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %lu.\n", desc.ddpfPixelFormat.dwRGBBitCount);
4164
4165 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1);
4166 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr);
4167
4168 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
4169 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
4170
4171 hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
4172 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4173
4174 surface_desc.dwSize = sizeof(surface_desc);
4175 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4176 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
4177 ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %lubpp.\n",
4178 surface_desc.ddpfPixelFormat.dwRGBBitCount);
4179
4180 hr = IDirectDraw2_RestoreDisplayMode(ddraw);
4181 ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
4182
4183 if (ds)
4184 IDirectDrawSurface_Release(ds);
4185 IDirectDrawSurface_Release(surface);
4186 IDirect3DDevice_Release(d3ddevice1);
4188 IDirect3DRM_Release(d3drm1);
4189 IDirectDrawClipper_Release(clipper);
4190 IDirectDraw_Release(ddraw);
4192}
#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:161
static HRESULT CALLBACK surface_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
Definition: d3drm.c:4010
DWORD IDirectDrawSurface7
Definition: vmrender.idl:20
BOOL WINAPI DestroyWindow(_In_ HWND)
#define DDSD_PIXELFORMAT
Definition: ddraw.h:218
#define DDSD_PITCH
Definition: ddraw.h:213
#define DDENUMSURFACES_ALL
Definition: ddraw.h:523
#define DD_OK
Definition: ddraw.h:188
#define DDENUMSURFACES_DOESEXIST
Definition: ddraw.h:527
#define DDERR_NOCLIPPERATTACHED
Definition: ddraw.h:144
static WORD const char * driver
Definition: odbccp32.c:56

Referenced by START_TEST().

◆ test_create_device_from_clipper2()

static void test_create_device_from_clipper2 ( void  )
static

Definition at line 4194 of file d3drm.c.

4195{
4196 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4197 IDirect3DRM *d3drm1 = NULL;
4198 IDirect3DRM2 *d3drm2 = NULL;
4199 IDirectDraw *ddraw = NULL;
4201 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
4202 IDirect3DDevice2 *d3ddevice2 = NULL;
4203 IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
4204 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
4205 IDirectDrawSurface7 *surface7 = NULL;
4206 DDSURFACEDESC desc, surface_desc;
4207 DWORD expected_flags, ret_val;
4208 HWND window;
4209 GUID driver = IID_IDirect3DRGBDevice;
4210 HRESULT hr;
4211 ULONG ref1, ref2, ref3, cref1, cref2;
4212 RECT rc;
4213
4215 GetClientRect(window, &rc);
4216 hr = DirectDrawCreateClipper(0, &clipper, NULL);
4217 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr);
4218 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
4219 ok(hr == DD_OK, "Cannot set HWnd to Clipper, hr %#lx.\n", hr);
4220
4221 hr = Direct3DRMCreate(&d3drm1);
4222 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
4223 ref1 = get_refcount((IUnknown *)d3drm1);
4224 cref1 = get_refcount((IUnknown *)clipper);
4225
4226 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
4227 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
4228 ref2 = get_refcount((IUnknown *)d3drm2);
4229
4230 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 0, 0, &device2);
4231 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
4232 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
4233
4234 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4235 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, NULL, &driver, 300, 200, &device2);
4236 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
4237
4238 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, NULL);
4239 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
4240
4241 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, &device2);
4242 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr);
4243 ref3 = get_refcount((IUnknown *)d3drm1);
4244 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
4245 ref3 = get_refcount((IUnknown *)d3drm2);
4246 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4247 cref2 = get_refcount((IUnknown *)clipper);
4248 ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %lu , cref2 = %lu.\n", cref1, cref2);
4249 ret_val = IDirect3DRMDevice2_GetWidth(device2);
4250 ok(ret_val == 300, "Expected device width = 300, got %lu.\n", ret_val);
4251 ret_val = IDirect3DRMDevice2_GetHeight(device2);
4252 ok(ret_val == 200, "Expected device height == 200, got %lu.\n", ret_val);
4253
4254 /* Fetch immediate mode device in order to access render target */
4255 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4256 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4257
4258 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4259 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4260
4261 hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
4262 ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got hr %#lx.\n", hr);
4263
4264 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4265 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
4266 ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface, hr %#lx.\n", hr);
4267 IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
4268 hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
4269 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4270 IUnknown_Release(unknown);
4271 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4272 NULL, &d3drm_primary, surface_callback);
4273 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
4274 ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
4275 hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
4276 ok(hr == DD_OK, "Cannot get attached clipper from primary surface, hr %#lx.\n", hr);
4277 ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
4278
4279 IDirectDrawClipper_Release(d3drm_clipper);
4280 IDirectDrawSurface_Release(d3drm_primary);
4281 IDirectDrawSurface7_Release(surface7);
4282 IDirectDraw_Release(ddraw);
4283
4284 /* Check properties of render target and depth surface */
4285 surface_desc.dwSize = sizeof(surface_desc);
4286 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4287 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
4288
4289 ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4290 surface_desc.dwWidth, surface_desc.dwHeight);
4291 ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
4292 "Unexpected caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
4294 ok(surface_desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, surface_desc.dwFlags);
4295
4297 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4298 desc.dwSize = sizeof(desc);
4299 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4300 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4301 ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %lu bpp, got %lu bpp.\n",
4302 surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
4303
4304 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4305 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4306
4307 desc.dwSize = sizeof(desc);
4308 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4309 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
4310
4311 ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4312 desc.dwWidth, desc.dwHeight);
4313 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
4315 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
4316 ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %lu.\n", desc.dwZBufferBitDepth);
4317 ok(!desc.ddpfPixelFormat.dwStencilBitMask, "Expected stencil mask %#lx.\n", desc.ddpfPixelFormat.dwStencilBitMask);
4318
4319 /* Release old objects and check refcount of device and clipper */
4320 IDirectDrawSurface_Release(ds);
4321 ds = NULL;
4322 IDirectDrawSurface_Release(surface);
4323 surface = NULL;
4324 IDirect3DDevice2_Release(d3ddevice2);
4325 d3ddevice2 = NULL;
4327 ref3 = get_refcount((IUnknown *)d3drm1);
4328 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
4329 ref3 = get_refcount((IUnknown *)d3drm2);
4330 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4331 cref2 = get_refcount((IUnknown *)clipper);
4332 ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %lu, cref2 = %lu.\n", cref1, cref2);
4333
4334 /* Test if render target format follows the screen format */
4335 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4336 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4337 hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
4338 ok(hr == DD_OK, "Cannot set display mode to 16bpp, hr %#lx.\n", hr);
4339
4340 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4341 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4342 ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %lu.\n", desc.ddpfPixelFormat.dwRGBBitCount);
4343
4344 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, rc.right, rc.bottom, &device2);
4345 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr);
4346
4347 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4348 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4349
4350 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4351 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4352
4353 surface_desc.dwSize = sizeof(surface_desc);
4354 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4355 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
4356 ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %lubpp.\n",
4357 surface_desc.ddpfPixelFormat.dwRGBBitCount);
4358
4359 hr = IDirectDraw2_RestoreDisplayMode(ddraw);
4360 ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
4361
4362 IDirectDrawSurface_Release(surface);
4363 IDirect3DDevice2_Release(d3ddevice2);
4365 IDirect3DRM2_Release(d3drm2);
4366 IDirect3DRM_Release(d3drm1);
4367 IDirectDrawClipper_Release(clipper);
4368 IDirectDraw_Release(ddraw);
4370}
#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 4372 of file d3drm.c.

4373{
4374 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4375 IDirect3DRM *d3drm1 = NULL;
4376 IDirect3DRM3 *d3drm3 = NULL;
4377 IDirectDraw *ddraw = NULL;
4379 IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
4380 IDirect3DDevice2 *d3ddevice2 = NULL;
4381 IDirect3DDevice3 *d3ddevice3 = NULL;
4382 IDirectDrawClipper *clipper = NULL, *d3drm_clipper = NULL;
4383 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_primary = NULL;
4384 IDirectDrawSurface7 *surface7 = NULL;
4385 DDSURFACEDESC desc, surface_desc;
4386 DWORD expected_flags, ret_val;
4387 HWND window;
4388 GUID driver = IID_IDirect3DRGBDevice;
4389 HRESULT hr;
4390 ULONG ref1, ref2, ref3, cref1, cref2;
4391 RECT rc;
4392
4394 GetClientRect(window, &rc);
4395 hr = DirectDrawCreateClipper(0, &clipper, NULL);
4396 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr);
4397 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
4398 ok(hr == DD_OK, "Cannot set HWnd to Clipper, hr %#lx.\n", hr);
4399
4400 hr = Direct3DRMCreate(&d3drm1);
4401 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
4402 ref1 = get_refcount((IUnknown *)d3drm1);
4403 cref1 = get_refcount((IUnknown *)clipper);
4404
4405 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
4406 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
4407 ref2 = get_refcount((IUnknown *)d3drm3);
4408
4409 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 0, 0, &device3);
4410 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
4411 ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
4412
4413 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4414 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, NULL, &driver, 300, 200, &device3);
4415 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
4416
4417 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 300, 200, NULL);
4418 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
4419
4420 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 300, 200, &device3);
4421 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
4422 ref3 = get_refcount((IUnknown *)d3drm1);
4423 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
4424 ref3 = get_refcount((IUnknown *)d3drm3);
4425 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4426 cref2 = get_refcount((IUnknown *)clipper);
4427 ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %lu , cref2 = %lu.\n", cref1, cref2);
4428 ret_val = IDirect3DRMDevice3_GetWidth(device3);
4429 ok(ret_val == 300, "Expected device width = 300, got %lu.\n", ret_val);
4430 ret_val = IDirect3DRMDevice3_GetHeight(device3);
4431 ok(ret_val == 200, "Expected device height == 200, got %lu.\n", ret_val);
4432
4433 /* Fetch immediate mode device in order to access render target */
4434 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4435 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4436
4437 hr = IDirect3DDevice2_QueryInterface(d3ddevice2, &IID_IDirect3DDevice3, (void**)&d3ddevice3);
4438 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4439 IDirect3DDevice3_Release(d3ddevice3);
4440
4441 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4442 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4443
4444 hr = IDirectDrawSurface_GetClipper(surface, &d3drm_clipper);
4445 ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got hr %#lx.\n", hr);
4446
4447 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4448 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
4449 ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 interface, hr %#lx.\n", hr);
4450 IDirectDrawSurface7_GetDDInterface(surface7, (void **)&unknown);
4451 hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void **)&ddraw);
4452 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4453 IUnknown_Release(unknown);
4454 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4455 NULL, &d3drm_primary, surface_callback);
4456 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
4457 ok(d3drm_primary != NULL, "No primary surface was enumerated.\n");
4458 hr = IDirectDrawSurface_GetClipper(d3drm_primary, &d3drm_clipper);
4459 ok(hr == DD_OK, "Cannot get attached clipper from primary surface, hr %#lx.\n", hr);
4460 ok(d3drm_clipper == clipper, "Expected clipper returned == %p, got %p.\n", clipper , d3drm_clipper);
4461
4462 IDirectDrawClipper_Release(d3drm_clipper);
4463 IDirectDrawSurface_Release(d3drm_primary);
4464 IDirectDrawSurface7_Release(surface7);
4465 IDirectDraw_Release(ddraw);
4466
4467 /* Check properties of render target and depth surface */
4468 surface_desc.dwSize = sizeof(surface_desc);
4469 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4470 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
4471
4472 ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4473 surface_desc.dwWidth, surface_desc.dwHeight);
4474 ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
4475 "Unexpected caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
4477 ok(surface_desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, surface_desc.dwFlags);
4478
4480 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4481 desc.dwSize = sizeof(desc);
4482 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4483 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4484 ok(desc.ddpfPixelFormat.dwRGBBitCount == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected %lu bpp, got %lu bpp.\n",
4485 surface_desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);
4486
4487 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4488 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4489
4490 desc.dwSize = sizeof(desc);
4491 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4492 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
4493
4494 ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4495 desc.dwWidth, desc.dwHeight);
4496 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
4498 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
4499 ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %lu.\n", desc.dwZBufferBitDepth);
4500 ok(!desc.ddpfPixelFormat.dwStencilBitMask, "Unexpected stencil mask %#lx.\n", desc.ddpfPixelFormat.dwStencilBitMask);
4501
4502 /* Release old objects and check refcount of device and clipper */
4503 IDirectDrawSurface_Release(ds);
4504 ds = NULL;
4505 IDirectDrawSurface_Release(surface);
4506 surface = NULL;
4507 IDirect3DDevice2_Release(d3ddevice2);
4508 d3ddevice2 = NULL;
4510 ref3 = get_refcount((IUnknown *)d3drm1);
4511 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
4512 ref3 = get_refcount((IUnknown *)d3drm3);
4513 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4514 cref2 = get_refcount((IUnknown *)clipper);
4515 ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %lu, cref2 = %lu.\n", cref1, cref2);
4516
4517 /* Test if render target format follows the screen format */
4518 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4519 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4520 hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
4521 ok(hr == DD_OK, "Cannot set display mode to 16bpp, hr %#lx.\n", hr);
4522
4523 hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
4524 ok(hr == DD_OK, "Cannot get IDirectDraw display mode, hr %#lx\n", hr);
4525 ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %lu.\n", desc.ddpfPixelFormat.dwRGBBitCount);
4526
4527 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
4528 ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
4529
4530 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4531 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4532
4533 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
4534 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4535
4536 surface_desc.dwSize = sizeof(surface_desc);
4537 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
4538 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
4539 ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %lubpp.\n",
4540 surface_desc.ddpfPixelFormat.dwRGBBitCount);
4541
4542 hr = IDirectDraw2_RestoreDisplayMode(ddraw);
4543 ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
4544
4545 IDirectDrawSurface_Release(surface);
4546 IDirect3DDevice2_Release(d3ddevice2);
4548 IDirect3DRM3_Release(d3drm3);
4549 IDirect3DRM_Release(d3drm1);
4550 IDirectDrawClipper_Release(clipper);
4551 IDirectDraw_Release(ddraw);
4553}
#define IDirect3DDevice2_QueryInterface(p, a, b)
Definition: d3d.h:1062
#define IDirect3DDevice3_Release(p)
Definition: d3d.h:1192
#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 5204 of file d3drm.c.

5205{
5206 IDirectDraw *ddraw1 = NULL, *temp_ddraw1;
5207 IDirect3D *d3d1 = NULL, *temp_d3d1;
5208 IDirect3DRM *d3drm1 = NULL;
5209 IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
5210 IDirect3DRMDevice2 *device2;
5211 IDirect3DRMDevice3 *device3;
5212 IDirect3DDevice *d3ddevice1 = NULL, *d3drm_d3ddevice1 = NULL, *temp_d3ddevice1;
5213 IDirect3DDevice2 *d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5214 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
5215 DWORD expected_flags, ret_val;
5216 DDSCAPS caps = { DDSCAPS_ZBUFFER };
5218 RECT rc;
5219 HWND window;
5220 ULONG ref1, ref2, ref3, ref4, device_ref1, device_ref2, d3d_ref1, d3d_ref2;
5221 HRESULT hr;
5222
5223 hr = DirectDrawCreate(NULL, &ddraw1, NULL);
5224 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
5225
5227 GetClientRect(window, &rc);
5228
5229 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D, (void **)&d3d1);
5230 ok(hr == DD_OK, "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
5231 d3d_ref1 = get_refcount((IUnknown *)d3d1);
5232
5233 /* Create the immediate mode device */
5234 d3ddevice1 = create_device1(ddraw1, window, &ds);
5235 if (d3ddevice1 == NULL)
5236 {
5237 win_skip("Cannot create IM device, skipping tests.\n");
5238 IDirect3D_Release(d3d1);
5239 IDirectDraw_Release(ddraw1);
5240 return;
5241 }
5242 device_ref1 = get_refcount((IUnknown *)d3ddevice1);
5243
5244 hr = Direct3DRMCreate(&d3drm1);
5245 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
5246 ref1 = get_refcount((IUnknown *)d3drm1);
5247
5248 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, NULL, d3ddevice1, &device1);
5249 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
5250 ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
5251 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, NULL, &device1);
5252 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5253 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, NULL);
5254 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5255
5256 hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, &device1);
5257 ok(hr == DD_OK, "Failed to create IDirect3DRMDevice interface, hr %#lx\n", hr);
5258 ref2 = get_refcount((IUnknown *)d3drm1);
5259 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
5260 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5261 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1, device_ref2);
5262 d3d_ref2 = get_refcount((IUnknown *)d3d1);
5263 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5264 ret_val = IDirect3DRMDevice_GetWidth(device1);
5265 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
5266 ret_val = IDirect3DRMDevice_GetHeight(device1);
5267 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
5268
5269 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2);
5270 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface, hr %#lx.\n", hr);
5271 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
5272 ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got hr %#lx.\n", hr);
5273 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5275
5276 d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5277 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3);
5278 ok(hr == DD_OK, "Cannot get IDirect3DRMDevice3 Interface, hr %#lx.\n", hr);
5279 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5280 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5281 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5283
5284 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5285 NULL, &surface, surface_callback);
5286 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
5287 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5288
5289 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
5290 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
5291 ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice1, d3drm_d3ddevice1);
5292
5293 /* Check properties of render target and depth surfaces */
5294 hr = IDirect3DDevice_QueryInterface(d3drm_d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
5295 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
5296
5297 memset(&desc, 0, sizeof(desc));
5298 desc.dwSize = sizeof(desc);
5299 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5300 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
5301
5302 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5303 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5305 "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
5307 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5308
5309 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5310 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5311 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5312
5313 desc.dwSize = sizeof(desc);
5314 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5315 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
5316
5317 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5318 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5319 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
5321 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5322
5323 IDirectDrawSurface_Release(d3drm_ds);
5324 IDirectDrawSurface_Release(ds);
5325 IDirectDrawSurface_Release(surface);
5326 IDirect3DDevice_Release(d3drm_d3ddevice1);
5328 ref2 = get_refcount((IUnknown *)d3drm1);
5329 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
5330 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5331 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1, device_ref2);
5332
5333 /* InitFromD3D tests */
5334 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice, (void **)&device1);
5335 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface, hr %#lx.\n", hr);
5336
5337 hr = IDirect3DRMDevice_InitFromD3D(device1, NULL, d3ddevice1);
5338 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5339 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, NULL);
5340 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5341
5342 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
5343 ok(SUCCEEDED(hr), "Failed to initialise IDirect3DRMDevice interface, hr %#lx\n", hr);
5344 ref2 = get_refcount((IUnknown *)d3drm1);
5345 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
5346 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5347 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5348 device_ref1, device_ref2);
5349 d3d_ref2 = get_refcount((IUnknown *)d3d1);
5350 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5351 ret_val = IDirect3DRMDevice_GetWidth(device1);
5352 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
5353 ret_val = IDirect3DRMDevice_GetHeight(device1);
5354 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
5355
5356 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
5357 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5358 ref3 = get_refcount((IUnknown *)d3drm1);
5359 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
5360 ref3 = get_refcount((IUnknown *)d3ddevice1);
5361 ok(ref3 > device_ref2, "Expected ref3 > device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3, device_ref2);
5362 ref3 = get_refcount((IUnknown *)d3d1);
5363 ok(ref3 > d3d_ref2, "Expected ref3 > d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3, d3d_ref2);
5364 /* Release leaked references */
5365 while (IDirect3DRM_Release(d3drm1) > ref2);
5366 while (IDirect3DDevice_Release(d3ddevice1) > device_ref2);
5367 while (IDirect3D_Release(d3d1) > d3d_ref2);
5368
5369 hr = DirectDrawCreate(NULL, &temp_ddraw1, NULL);
5370 ok(SUCCEEDED(hr), "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
5371 ref4 = get_refcount((IUnknown *)temp_ddraw1);
5372
5373 hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirect3D, (void **)&temp_d3d1);
5374 ok(SUCCEEDED(hr), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
5375 temp_d3ddevice1 = create_device1(temp_ddraw1, window, &surface);
5376 hr = IDirect3DRMDevice_InitFromD3D(device1, temp_d3d1, temp_d3ddevice1);
5377 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5378 ref3 = get_refcount((IUnknown *)d3drm1);
5379 ok(ref3 > ref2, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
5380 ref3 = get_refcount((IUnknown *)temp_d3ddevice1);
5381 ok(ref3 == device_ref2, "Expected ref3 == device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3, device_ref2);
5382 ref3 = get_refcount((IUnknown *)temp_d3d1);
5383 todo_wine ok(ref3 < d3d_ref2, "Expected ref3 < d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3, d3d_ref2);
5384 /* Release leaked references */
5385 while (IDirect3DRM_Release(d3drm1) > ref2);
5386 while (IDirect3DDevice_Release(temp_d3ddevice1) > 0);
5387 while (IDirect3D_Release(temp_d3d1) > ref4);
5388 IDirectDrawSurface_Release(surface);
5389 IDirectDraw_Release(temp_ddraw1);
5390
5391 d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5392 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2);
5393 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface, hr %#lx.\n", hr);
5394 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
5395 ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got hr %#lx.\n", hr);
5396 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5398
5399 d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef;
5400 hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3);
5401 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 Interface, hr %#lx.\n", hr);
5402 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5403 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5404 ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2);
5406
5407 surface = NULL;
5408 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5409 NULL, &surface, surface_callback);
5410 ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
5411 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5412
5413 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
5414 ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
5415 ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode device created == %p, got %p.\n",
5416 d3ddevice1, d3drm_d3ddevice1);
5417
5418 /* Check properties of render target and depth surfaces */
5419 hr = IDirect3DDevice_QueryInterface(d3drm_d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
5420 ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
5421
5422 memset(&desc, 0, sizeof(desc));
5423 desc.dwSize = sizeof(desc);
5424 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5425 ok(SUCCEEDED(hr), "Cannot get surface desc structure, hr %#lx.\n", hr);
5426
5427 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5428 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5430 "Unexpected caps got %lx.\n", desc.ddsCaps.dwCaps);
5432 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5433
5434 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5435 ok(SUCCEEDED(hr), "Cannot get attached depth surface, hr %#lx.\n", hr);
5436 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5437
5438 desc.dwSize = sizeof(desc);
5439 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5440 ok(SUCCEEDED(hr), "Cannot get z surface desc structure, hr %#lx.\n", hr);
5441
5442 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5443 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5444 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
5446 ok(desc.dwFlags == expected_flags, "Expected %#lx for flags, got %#lx.\n", expected_flags, desc.dwFlags);
5447
5448 IDirectDrawSurface_Release(d3drm_ds);
5449 IDirectDrawSurface_Release(ds);
5450 IDirectDrawSurface_Release(surface);
5451 IDirect3DDevice_Release(d3drm_d3ddevice1);
5453 ref2 = get_refcount((IUnknown *)d3drm1);
5454 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
5455 device_ref2 = get_refcount((IUnknown *)d3ddevice1);
5456 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5457 device_ref1, device_ref2);
5458 d3d_ref2 = get_refcount((IUnknown *)d3d1);
5459 todo_wine ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1,
5460 d3d_ref2);
5461
5462 IDirect3DRM_Release(d3drm1);
5463 IDirect3DDevice_Release(d3ddevice1);
5464 IDirect3D_Release(d3d1);
5465 IDirectDraw_Release(ddraw1);
5467}
#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
#define win_skip
Definition: minitest.h:67
static IDirect3DDevice * create_device1(IDirectDraw *ddraw, HWND window, IDirectDrawSurface **ds)
Definition: d3drm.c:5145

Referenced by START_TEST().

◆ test_create_device_from_d3d2()

static void test_create_device_from_d3d2 ( void  )
static

Definition at line 5538 of file d3drm.c.

5539{
5540 IDirectDraw *ddraw1 = NULL, *temp_ddraw1;
5541 IDirectDraw2 *ddraw2 = NULL, *temp_ddraw2;
5542 IDirect3D* d3d1;
5543 IDirect3D2 *d3d2 = NULL, *temp_d3d2;
5544 IDirect3DRM *d3drm1 = NULL;
5545 IDirect3DRM2 *d3drm2 = NULL;
5546 IDirect3DRMDevice *device1;
5547 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
5548 IDirect3DDevice *d3ddevice1;
5549 IDirect3DDevice2 *d3ddevice2 = NULL, *d3drm_d3ddevice2 = NULL, *temp_d3ddevice2;
5550 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
5551 DWORD expected_flags, ret_val;
5552 DDSCAPS caps = { DDSCAPS_ZBUFFER };
5554 RECT rc;
5555 HWND window;
5556 ULONG ref1, ref2, ref3, ref4, ref5, device_ref1, device_ref2, d3d_ref1, d3d_ref2;
5557 HRESULT hr;
5558
5559 hr = DirectDrawCreate(NULL, &ddraw1, NULL);
5560 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
5561
5563 GetClientRect(window, &rc);
5564
5565 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D2, (void **)&d3d2);
5566 ok(hr == DD_OK, "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
5567 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
5568 ok(hr == DD_OK, "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr);
5569 d3d_ref1 = get_refcount((IUnknown *)d3d2);
5570
5571 /* Create the immediate mode device */
5572 d3ddevice2 = create_device2(ddraw2, window, &ds);
5573 if (d3ddevice2 == NULL)
5574 {
5575 win_skip("Cannot create IM device, skipping tests.\n");
5576 IDirect3D2_Release(d3d2);
5577 IDirectDraw2_Release(ddraw2);
5578 IDirectDraw_Release(ddraw1);
5579 return;
5580 }
5581 device_ref1 = get_refcount((IUnknown *)d3ddevice2);
5582
5583 hr = Direct3DRMCreate(&d3drm1);
5584 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
5585 ref1 = get_refcount((IUnknown *)d3drm1);
5586
5587 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
5588 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
5589 ref2 = get_refcount((IUnknown *)d3drm2);
5590
5591 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, NULL, d3ddevice2, &device2);
5592 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
5593 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
5594 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, d3d2, NULL, &device2);
5595 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
5596 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, d3d2, d3ddevice2, NULL);
5597 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5598
5599 hr = IDirect3DRM2_CreateDeviceFromD3D(d3drm2, d3d2, d3ddevice2, &device2);
5600 ok(hr == DD_OK, "Failed to create IDirect3DRMDevice2 interface, hr %#lx\n", hr);
5601 ref3 = get_refcount((IUnknown *)d3drm1);
5602 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
5603 ref3 = get_refcount((IUnknown *)d3drm2);
5604 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
5605 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5606 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1, device_ref2);
5607 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5608 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5609 ret_val = IDirect3DRMDevice2_GetWidth(device2);
5610 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
5611 ret_val = IDirect3DRMDevice2_GetHeight(device2);
5612 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
5613
5614 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5615 NULL, &surface, surface_callback);
5616 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
5617 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5618
5619 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3drm_d3ddevice2);
5620 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
5621 ok(d3ddevice2 == d3drm_d3ddevice2, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2, d3drm_d3ddevice2);
5622
5623 /* Check properties of render target and depth surfaces */
5624 hr = IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2, &surface);
5625 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
5626
5627 memset(&desc, 0, sizeof(desc));
5628 desc.dwSize = sizeof(desc);
5629 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5630 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
5631
5632 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5633 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5635 "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
5637 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5638
5639 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5640 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5641 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5642
5643 desc.dwSize = sizeof(desc);
5644 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5645 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
5646
5647 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5648 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5649 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
5651 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5652
5653 IDirectDrawSurface_Release(d3drm_ds);
5654 IDirectDrawSurface_Release(ds);
5655 IDirectDrawSurface_Release(surface);
5656 IDirect3DDevice2_Release(d3drm_d3ddevice2);
5658 ref3 = get_refcount((IUnknown *)d3drm1);
5659 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
5660 ref3 = get_refcount((IUnknown *)d3drm2);
5661 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
5662 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5663 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1, device_ref2);
5664 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5665 ok(d3d_ref2 == d3d_ref1, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5666
5667 /* InitFromD3D tests */
5668 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice2, (void **)&device2);
5669 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 interface, hr %#lx.\n", hr);
5670
5671 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D, (void **)&d3d1);
5672 ok(SUCCEEDED(hr), "Cannot get IDirect3D interface, hr %#lx.\n", hr);
5673 if (SUCCEEDED(hr = IDirect3DDevice2_QueryInterface(d3ddevice2, &IID_IDirect3DDevice, (void **)&d3ddevice1)))
5674 {
5675 hr = IDirect3DRMDevice2_InitFromD3D(device2, d3d1, d3ddevice1);
5676 ok(hr == E_NOINTERFACE, "Expected hr == E_NOINTERFACE, got hr %#lx.\n", hr);
5677 hr = IDirect3DRMDevice2_InitFromD3D(device2, NULL, d3ddevice1);
5678 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5679 hr = IDirect3DRMDevice2_InitFromD3D(device2, d3d1, NULL);
5680 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5681 hr = IDirect3DRMDevice2_QueryInterface(device2, &IID_IDirect3DRMDevice, (void **)&device1);
5682 ok(SUCCEEDED(hr), "Cannot obtain IDirect3DRMDevice interface, hr %#lx.\n", hr);
5683 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
5684 todo_wine ok(hr == E_NOINTERFACE, "Expected hr == E_NOINTERFACE, got hr %#lx.\n", hr);
5686 if (SUCCEEDED(hr))
5687 {
5689 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice2,
5690 (void **)&device2);
5691 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 interface, hr %#lx.\n", hr);
5692 }
5693 }
5694 IDirect3D_Release(d3d1);
5695 IDirect3DDevice_Release(d3ddevice1);
5696
5697 hr = IDirect3DRMDevice2_InitFromD3D2(device2, NULL, d3ddevice2);
5698 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5699 hr = IDirect3DRMDevice2_InitFromD3D2(device2, d3d2, NULL);
5700 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5701
5702 hr = IDirect3DRMDevice2_InitFromD3D2(device2, d3d2, d3ddevice2);
5703 ok(SUCCEEDED(hr), "Failed to initialise IDirect3DRMDevice2 interface, hr %#lx\n", hr);
5704 ref4 = get_refcount((IUnknown *)d3drm1);
5705 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
5706 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5707 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5708 device_ref1, device_ref2);
5709 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5710 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5711 ret_val = IDirect3DRMDevice2_GetWidth(device2);
5712 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
5713 ret_val = IDirect3DRMDevice2_GetHeight(device2);
5714 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
5715
5716 hr = IDirect3DRMDevice2_InitFromD3D2(device2, d3d2, d3ddevice2);
5717 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5718 ref3 = get_refcount((IUnknown *)d3drm1);
5719 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
5720 ref3 = get_refcount((IUnknown *)d3ddevice2);
5721 ok(ref3 > device_ref2, "Expected ref3 > device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3, device_ref2);
5722 ref3 = get_refcount((IUnknown *)d3d2);
5723 ok(ref3 > d3d_ref2, "Expected ref3 > d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3, d3d_ref2);
5724 /* Release leaked references */
5725 while (IDirect3DRM_Release(d3drm1) > ref4);
5726 while (IDirect3DDevice2_Release(d3ddevice2) > device_ref2);
5727 while (IDirect3D2_Release(d3d2) > d3d_ref2);
5728
5729 hr = DirectDrawCreate(NULL, &temp_ddraw1, NULL);
5730 ok(SUCCEEDED(hr), "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
5731 hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirect3D2, (void **)&temp_d3d2);
5732 ok(SUCCEEDED(hr), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
5733 ref5 = get_refcount((IUnknown *)temp_d3d2);
5734
5735 hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirectDraw2, (void **)&temp_ddraw2);
5736 ok(SUCCEEDED(hr), "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr);
5737
5738 temp_d3ddevice2 = create_device2(temp_ddraw2, window, &surface);
5739 hr = IDirect3DRMDevice2_InitFromD3D2(device2, temp_d3d2, temp_d3ddevice2);
5740 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5741 ref3 = get_refcount((IUnknown *)d3drm1);
5742 ok(ref3 > ref4, "expected ref3 > ref4, got ref3 = %lu , ref4 = %lu.\n", ref3, ref4);
5743 ref3 = get_refcount((IUnknown *)temp_d3ddevice2);
5744 ok(ref3 == device_ref2, "Expected ref3 == device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3, device_ref2);
5745 ref3 = get_refcount((IUnknown *)temp_d3d2);
5746 ok(ref3 == d3d_ref2, "Expected ref3 == d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3, d3d_ref2);
5747 /* Release leaked references */
5748 while (IDirect3DRM_Release(d3drm1) > ref4);
5749 while (IDirect3DDevice2_Release(temp_d3ddevice2) > 0);
5750 while (IDirect3D2_Release(temp_d3d2) >= ref5);
5751 IDirectDrawSurface_Release(surface);
5752 IDirectDraw2_Release(temp_ddraw2);
5753 IDirectDraw_Release(temp_ddraw1);
5754
5755 surface = NULL;
5756 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5757 NULL, &surface, surface_callback);
5758 ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
5759 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5760
5761 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3drm_d3ddevice2);
5762 ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
5763 ok(d3ddevice2 == d3drm_d3ddevice2, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2,
5764 d3drm_d3ddevice2);
5765
5766 /* Check properties of render target and depth surfaces */
5767 hr = IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2, &surface);
5768 ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
5769
5770 memset(&desc, 0, sizeof(desc));
5771 desc.dwSize = sizeof(desc);
5772 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5773 ok(SUCCEEDED(hr), "Cannot get surface desc structure, hr %#lx.\n", hr);
5774
5775 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5776 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5778 "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
5780 ok(desc.dwFlags == expected_flags, "Expected %#lx for flags, got %#lx.\n", expected_flags, desc.dwFlags);
5781
5782 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5783 ok(SUCCEEDED(hr), "Cannot get attached depth surface, hr %#lx.\n", hr);
5784 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5785
5786 desc.dwSize = sizeof(desc);
5787 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5788 ok(SUCCEEDED(hr), "Cannot get z surface desc structure, hr %#lx.\n", hr);
5789
5790 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5791 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5792 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
5794 ok(desc.dwFlags == expected_flags, "Expected %#lx for flags, got %#lx.\n", expected_flags, desc.dwFlags);
5795
5796 IDirectDrawSurface_Release(d3drm_ds);
5797 IDirectDrawSurface_Release(ds);
5798 IDirectDrawSurface_Release(surface);
5799 IDirect3DDevice2_Release(d3drm_d3ddevice2);
5801 ref3 = get_refcount((IUnknown *)d3drm1);
5802 ok(ref1 == ref3, "Expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
5803 ref3 = get_refcount((IUnknown *)d3drm2);
5804 ok(ref3 == ref2, "Expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
5805 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5806 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5807 device_ref1, device_ref2);
5808 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5809 ok(d3d_ref2 == d3d_ref1, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5810
5811 IDirect3DRM2_Release(d3drm2);
5812 IDirect3DRM_Release(d3drm1);
5813 IDirect3DDevice2_Release(d3ddevice2);
5814 IDirect3D2_Release(d3d2);
5815 IDirectDraw2_Release(ddraw2);
5816 IDirectDraw_Release(ddraw1);
5818}
#define IDirect3DRM2_CreateObject(p, a, b, c, d)
Definition: d3drm.h:254
#define IDirect3DRM2_CreateDeviceFromD3D(p, a, b, c)
Definition: d3drm.h:267
#define IDirect3DRMDevice2_QueryInterface(p, a, b)
Definition: d3drmobj.h:540
#define IDirect3DRMDevice2_InitFromD3D(p, a, b)
Definition: d3drmobj.h:554
#define IDirect3DRMDevice2_InitFromD3D2(p, a, b)
Definition: d3drmobj.h:577
static IDirect3DDevice2 * create_device2(IDirectDraw2 *ddraw, HWND window, IDirectDrawSurface **ds)
Definition: d3drm.c:5469
#define E_NOINTERFACE
Definition: winerror.h:3479

Referenced by START_TEST().

◆ test_create_device_from_d3d3()

static void test_create_device_from_d3d3 ( void  )
static

Definition at line 5820 of file d3drm.c.

5821{
5822 IDirectDraw *ddraw1 = NULL, *temp_ddraw1;
5823 IDirectDraw2 *ddraw2 = NULL, *temp_ddraw2;
5824 IDirect3D *d3d1;
5825 IDirect3D2 *d3d2 = NULL, *temp_d3d2;
5826 IDirect3DRM *d3drm1 = NULL;
5827 IDirect3DRM3 *d3drm3 = NULL;
5828 IDirect3DRMDevice *device1;
5829 IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
5830 IDirect3DDevice *d3ddevice1;
5831 IDirect3DDevice2 *d3ddevice2 = NULL, *d3drm_d3ddevice2 = NULL, *temp_d3ddevice2;
5832 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
5833 DWORD expected_flags, ret_val;
5834 DDSCAPS caps = { DDSCAPS_ZBUFFER };
5836 RECT rc;
5837 HWND window;
5838 ULONG ref1, ref2, ref3, ref4, ref5, device_ref1, device_ref2, d3d_ref1, d3d_ref2;
5839 HRESULT hr;
5840
5841 hr = DirectDrawCreate(NULL, &ddraw1, NULL);
5842 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
5843
5845 GetClientRect(window, &rc);
5846
5847 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D2, (void **)&d3d2);
5848 ok(hr == DD_OK, "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
5849 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
5850 ok(hr == DD_OK, "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr);
5851 d3d_ref1 = get_refcount((IUnknown *)d3d2);
5852
5853 /* Create the immediate mode device */
5854 d3ddevice2 = create_device2(ddraw2, window, &ds);
5855 if (d3ddevice2 == NULL)
5856 {
5857 win_skip("Cannot create IM device, skipping tests.\n");
5858 IDirect3D2_Release(d3d2);
5859 IDirectDraw2_Release(ddraw2);
5860 IDirectDraw_Release(ddraw1);
5861 return;
5862 }
5863 device_ref1 = get_refcount((IUnknown *)d3ddevice2);
5864
5865 hr = Direct3DRMCreate(&d3drm1);
5866 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
5867 ref1 = get_refcount((IUnknown *)d3drm1);
5868
5869 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
5870 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
5871 ref2 = get_refcount((IUnknown *)d3drm3);
5872
5873 hr = IDirect3DRM3_CreateDeviceFromD3D(d3drm3, NULL, d3ddevice2, &device3);
5874 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
5875 ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
5876 hr = IDirect3DRM3_CreateDeviceFromD3D(d3drm3, d3d2, NULL, &device3);
5877 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5878 hr = IDirect3DRM3_CreateDeviceFromD3D(d3drm3, d3d2, d3ddevice2, NULL);
5879 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5880
5881 hr = IDirect3DRM3_CreateDeviceFromD3D(d3drm3, d3d2, d3ddevice2, &device3);
5882 ok(hr == DD_OK, "Failed to create IDirect3DRMDevice3 interface, hr %#lx\n", hr);
5883 ref3 = get_refcount((IUnknown *)d3drm1);
5884 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
5885 ref3 = get_refcount((IUnknown *)d3drm3);
5886 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
5887 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5888 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1, device_ref2);
5889 ret_val = IDirect3DRMDevice3_GetWidth(device3);
5890 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
5891 ret_val = IDirect3DRMDevice3_GetHeight(device3);
5892 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
5893
5894 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
5895 NULL, &surface, surface_callback);
5896 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
5897 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
5898
5899 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3drm_d3ddevice2);
5900 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
5901 ok(d3ddevice2 == d3drm_d3ddevice2, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2, d3drm_d3ddevice2);
5902
5903 /* Check properties of render target and depth surfaces */
5904 hr = IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2, &surface);
5905 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
5906
5907 memset(&desc, 0, sizeof(desc));
5908 desc.dwSize = sizeof(desc);
5909 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
5910 ok(hr == DD_OK, "Cannot get surface desc structure, hr %#lx.\n", hr);
5911
5912 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5913 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5915 "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
5917 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5918
5919 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
5920 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5921 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5922
5923 desc.dwSize = sizeof(desc);
5924 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5925 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
5926
5927 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5928 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5929 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
5931 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5932
5933 IDirectDrawSurface_Release(d3drm_ds);
5934 IDirectDrawSurface_Release(ds);
5935 IDirectDrawSurface_Release(surface);
5936 IDirect3DDevice2_Release(d3drm_d3ddevice2);
5938 ref3 = get_refcount((IUnknown *)d3drm1);
5939 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
5940 ref3 = get_refcount((IUnknown *)d3drm3);
5941 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
5942 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5943 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1, device_ref2);
5944 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5945 ok(d3d_ref2 == d3d_ref1, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5946
5947 /* InitFromD3D tests */
5948 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice3, (void **)&device3);
5949 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
5950
5951 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D, (void **)&d3d1);
5952 ok(SUCCEEDED(hr), "Cannot get IDirect3D interface, hr %#lx.\n", hr);
5953 if (SUCCEEDED(hr = IDirect3DDevice2_QueryInterface(d3ddevice2, &IID_IDirect3DDevice, (void **)&d3ddevice1)))
5954 {
5955 hr = IDirect3DRMDevice3_InitFromD3D(device3, d3d1, d3ddevice1);
5956 ok(hr == E_NOINTERFACE, "Expected hr == E_NOINTERFACE, got hr %#lx.\n", hr);
5957 hr = IDirect3DRMDevice3_InitFromD3D(device3, NULL, d3ddevice1);
5958 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5959 hr = IDirect3DRMDevice3_InitFromD3D(device3, d3d1, NULL);
5960 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5961 hr = IDirect3DRMDevice3_QueryInterface(device3, &IID_IDirect3DRMDevice, (void **)&device1);
5962 ok(SUCCEEDED(hr), "Cannot obtain IDirect3DRMDevice interface, hr %#lx.\n", hr);
5963 hr = IDirect3DRMDevice_InitFromD3D(device1, d3d1, d3ddevice1);
5964 todo_wine ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
5966 if (SUCCEEDED(hr))
5967 {
5969 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMDevice, NULL, &IID_IDirect3DRMDevice3,
5970 (void **)&device3);
5971 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
5972 }
5973 }
5974 IDirect3D_Release(d3d1);
5975 IDirect3DDevice_Release(d3ddevice1);
5976
5977 hr = IDirect3DRMDevice3_InitFromD3D2(device3, NULL, d3ddevice2);
5978 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5979 hr = IDirect3DRMDevice3_InitFromD3D2(device3, d3d2, NULL);
5980 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
5981
5982 hr = IDirect3DRMDevice3_InitFromD3D2(device3, d3d2, d3ddevice2);
5983 ok(SUCCEEDED(hr), "Failed to initialise IDirect3DRMDevice2 interface, hr %#lx\n", hr);
5984 ref4 = get_refcount((IUnknown *)d3drm1);
5985 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
5986 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
5987 ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5988 device_ref1, device_ref2);
5989 d3d_ref2 = get_refcount((IUnknown *)d3d2);
5990 ok(d3d_ref2 > d3d_ref1, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
5991 ret_val = IDirect3DRMDevice3_GetWidth(device3);
5992 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
5993 ret_val = IDirect3DRMDevice3_GetHeight(device3);
5994 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
5995
5996 hr = IDirect3DRMDevice3_InitFromD3D2(device3, d3d2, d3ddevice2);
5997 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
5998 ref3 = get_refcount((IUnknown *)d3drm1);
5999 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
6000 ref3 = get_refcount((IUnknown *)d3ddevice2);
6001 ok(ref3 > device_ref2, "Expected ref3 > device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3, device_ref2);
6002 ref3 = get_refcount((IUnknown *)d3d2);
6003 ok(ref3 > d3d_ref2, "Expected ref3 > d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3, d3d_ref2);
6004 /* Release leaked references */
6005 while (IDirect3DRM_Release(d3drm1) > ref4);
6006 while (IDirect3DDevice2_Release(d3ddevice2) > device_ref2);
6007 while (IDirect3D2_Release(d3d2) > d3d_ref2);
6008
6009 hr = DirectDrawCreate(NULL, &temp_ddraw1, NULL);
6010 ok(SUCCEEDED(hr), "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
6011 hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirect3D2, (void **)&temp_d3d2);
6012 ok(SUCCEEDED(hr), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
6013 ref5 = get_refcount((IUnknown *)temp_d3d2);
6014
6015 hr = IDirectDraw_QueryInterface(temp_ddraw1, &IID_IDirectDraw2, (void **)&temp_ddraw2);
6016 ok(SUCCEEDED(hr), "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr);
6017
6018 temp_d3ddevice2 = create_device2(temp_ddraw2, window, &surface);
6019 hr = IDirect3DRMDevice3_InitFromD3D2(device3, temp_d3d2, temp_d3ddevice2);
6020 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
6021 ref3 = get_refcount((IUnknown *)d3drm1);
6022 ok(ref3 > ref4, "expected ref3 > ref4, got ref3 = %lu , ref4 = %lu.\n", ref3, ref4);
6023 ref3 = get_refcount((IUnknown *)temp_d3ddevice2);
6024 ok(ref3 == device_ref2, "Expected ref3 == device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3, device_ref2);
6025 ref3 = get_refcount((IUnknown *)temp_d3d2);
6026 ok(ref3 == d3d_ref2, "Expected ref3 == d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3, d3d_ref2);
6027 /* Release leaked references */
6028 while (IDirect3DRM_Release(d3drm1) > ref4);
6029 while (IDirect3DDevice2_Release(temp_d3ddevice2) > 0);
6030 while (IDirect3D2_Release(temp_d3d2) >= ref5);
6031 IDirectDrawSurface_Release(surface);
6032 IDirectDraw2_Release(temp_ddraw2);
6033 IDirectDraw_Release(temp_ddraw1);
6034
6035 surface = NULL;
6036 hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
6037 NULL, &surface, surface_callback);
6038 ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
6039 ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
6040
6041 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3drm_d3ddevice2);
6042 ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
6043 ok(d3ddevice2 == d3drm_d3ddevice2, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2,
6044 d3drm_d3ddevice2);
6045
6046 /* Check properties of render target and depth surfaces */
6047 hr = IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2, &surface);
6048 ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
6049
6050 memset(&desc, 0, sizeof(desc));
6051 desc.dwSize = sizeof(desc);
6052 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
6053 ok(SUCCEEDED(hr), "Cannot get surface desc structure, hr %#lx.\n", hr);
6054
6055 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
6056 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
6058 "Unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
6060 ok(desc.dwFlags == expected_flags, "Expected %#lx for flags, got %#lx.\n", expected_flags, desc.dwFlags);
6061
6062 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
6063 ok(SUCCEEDED(hr), "Cannot get attached depth surface, hr %#lx.\n", hr);
6064 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
6065
6066 desc.dwSize = sizeof(desc);
6067 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
6068 ok(SUCCEEDED(hr), "Cannot get z surface desc structure, hr %#lx.\n", hr);
6069
6070 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
6071 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
6072 ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Unexpected caps %#lx.\n",desc.ddsCaps.dwCaps);
6074 ok(desc.dwFlags == expected_flags, "Expected %#lx for flags, got %#lx.\n", expected_flags, desc.dwFlags);
6075
6076 IDirectDrawSurface_Release(d3drm_ds);
6077 IDirectDrawSurface_Release(ds);
6078 IDirectDrawSurface_Release(surface);
6079 IDirect3DDevice2_Release(d3drm_d3ddevice2);
6081 ref3 = get_refcount((IUnknown *)d3drm1);
6082 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
6083 ref3 = get_refcount((IUnknown *)d3drm3);
6084 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
6085 device_ref2 = get_refcount((IUnknown *)d3ddevice2);
6086 ok(device_ref2 == device_ref1, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
6087 device_ref1, device_ref2);
6088 d3d_ref2 = get_refcount((IUnknown *)d3d2);
6089 ok(d3d_ref2 == d3d_ref1, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1, d3d_ref2);
6090
6091 IDirect3DRM3_Release(d3drm3);
6092 IDirect3DRM_Release(d3drm1);
6093 IDirect3DDevice2_Release(d3ddevice2);
6094 IDirect3D2_Release(d3d2);
6095 IDirectDraw2_Release(ddraw2);
6096 IDirectDraw_Release(ddraw1);
6098}
#define IDirect3DRM3_CreateDeviceFromD3D(p, a, b, c)
Definition: d3drm.h:415
#define IDirect3DRM3_CreateObject(p, a, b, c, d)
Definition: d3drm.h:402
#define IDirect3DRMDevice3_QueryInterface(p, a, b)
Definition: d3drmobj.h:691
#define IDirect3DRMDevice3_InitFromD3D(p, a, b)
Definition: d3drmobj.h:705
#define IDirect3DRMDevice3_InitFromD3D2(p, a, b)
Definition: d3drmobj.h:728

Referenced by START_TEST().

◆ test_create_device_from_surface1()

static void test_create_device_from_surface1 ( void  )
static

Definition at line 4555 of file d3drm.c.

4556{
4557 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4559 IDirectDraw *ddraw = NULL;
4560 IDirect3DRM *d3drm1 = NULL;
4561 IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
4562 IDirect3DDevice *d3ddevice1 = NULL;
4563 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_surface = NULL, *d3drm_ds = NULL;
4564 DWORD expected_flags, ret_val;
4565 HWND window;
4566 GUID driver = IID_IDirect3DRGBDevice;
4567 ULONG ref1, ref2, surface_ref1, surface_ref2;
4568 RECT rc;
4569 BOOL use_sysmem_zbuffer = FALSE;
4570 HRESULT hr;
4571
4573 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4574
4576 GetClientRect(window, &rc);
4577
4578 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
4579 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
4580
4581 hr = Direct3DRMCreate(&d3drm1);
4582 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
4583 ref1 = get_refcount((IUnknown *)d3drm1);
4584
4585 /* Create a surface and use it to create the retained mode device. */
4586 memset(&desc, 0, sizeof(desc));
4587 desc.dwSize = sizeof(desc);
4588 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4589 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
4590 desc.dwWidth = rc.right;
4591 desc.dwHeight = rc.bottom;
4592
4593 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4594 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4595
4596 hr = IDirect3DRM_CreateDeviceFromSurface(d3drm1, &driver, ddraw, surface, &device1);
4597 ok(hr == DDERR_INVALIDCAPS, "Expected hr == DDERR_INVALIDCAPS, got hr %#lx.\n", hr);
4598 ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
4599 IDirectDrawSurface_Release(surface);
4600
4601 desc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
4602 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4603 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4604 surface_ref1 = get_refcount((IUnknown *)surface);
4605
4607 ok(hr == D3DRMERR_BADVALUE, "Expected hr == DDERR_BADVALUE, got hr %#lx.\n", hr);
4608 hr = IDirect3DRM_CreateDeviceFromSurface(d3drm1, &driver, ddraw, NULL, &device1);
4609 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr);
4610 hr = IDirect3DRM_CreateDeviceFromSurface(d3drm1, &driver, NULL, surface, &device1);
4611 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr);
4612
4613 hr = IDirect3DRM_CreateDeviceFromSurface(d3drm1, &driver, ddraw, surface, &device1);
4614 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr);
4615 ref2 = get_refcount((IUnknown *)d3drm1);
4616 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
4617 surface_ref2 = get_refcount((IUnknown *)surface);
4618 ok(surface_ref2 > surface_ref1, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n", surface_ref1, surface_ref2);
4619 ret_val = IDirect3DRMDevice_GetWidth(device1);
4620 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
4621 ret_val = IDirect3DRMDevice_GetHeight(device1);
4622 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
4623
4624 /* Check if CreateDeviceFromSurface creates a primary surface */
4625 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4626 NULL, &d3drm_surface, surface_callback);
4627 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
4628 ok(d3drm_surface == NULL, "No primary surface should have enumerated (%p).\n", d3drm_surface);
4629
4630 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
4631 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
4632
4633 hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&d3drm_surface);
4634 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4635 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
4636
4637 /* Check properties of attached depth surface */
4638 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &ds);
4639 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4640
4641 memset(&desc, 0, sizeof(desc));
4642 desc.dwSize = sizeof(desc);
4643 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4644 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
4645
4646 use_sysmem_zbuffer = desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
4647 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
4648 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
4649 ok(desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER, "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
4651 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
4652
4653 IDirectDrawSurface_Release(ds);
4654 IDirect3DDevice_Release(d3ddevice1);
4655 IDirectDrawSurface_Release(d3drm_surface);
4656
4658 ref2 = get_refcount((IUnknown *)d3drm1);
4659 ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
4660 surface_ref2 = get_refcount((IUnknown *)surface);
4661 ok(surface_ref2 == surface_ref1, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n",
4662 surface_ref1, surface_ref2);
4663 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4664 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4665 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4666 ref1 = IDirectDrawSurface_Release(ds);
4667 ok(ref1 == 1, "Unexpected refcount %lu.\n", ref1);
4668 ref1 = IDirectDrawSurface_Release(surface);
4669 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
4670
4671 memset(&desc, 0, sizeof(desc));
4672 desc.dwSize = sizeof(desc);
4673 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4674 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
4675 desc.dwWidth = rc.right;
4676 desc.dwHeight = rc.bottom;
4677
4678 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4679 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4680
4681 memset(&desc, 0, sizeof(desc));
4682 desc.dwSize = sizeof(desc);
4684 desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | (use_sysmem_zbuffer ? DDSCAPS_SYSTEMMEMORY : 0);
4685 desc.dwZBufferBitDepth = 16;
4686 desc.dwWidth = rc.right;
4687 desc.dwHeight = rc.bottom;
4688 hr = IDirectDraw_CreateSurface(ddraw, &desc, &ds, NULL);
4689 ok(hr == DD_OK, "Cannot create depth surface, hr %#lx.\n", hr);
4690 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
4691 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
4692
4693 hr = IDirect3DRM_CreateDeviceFromSurface(d3drm1, &driver, ddraw, surface, &device1);
4694 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr);
4695
4696 hr = IDirect3DRMDevice2_GetDirect3DDevice(device1, &d3ddevice1);
4697 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
4698
4699 hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&d3drm_surface);
4700 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4701 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
4702
4703 /* Check if depth surface matches the one we created */
4704 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &d3drm_ds);
4705 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4706 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
4707
4708 IDirectDrawSurface_Release(d3drm_ds);
4709 IDirectDrawSurface_Release(d3drm_surface);
4710 IDirectDrawSurface_Release(ds);
4711
4712 IDirect3DDevice_Release(d3ddevice1);
4714 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4715 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4716 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4717 ref1 = IDirectDrawSurface_Release(ds);
4718 ok(ref1 == 1, "Unexpected refcount %lu.\n", ref1);
4719 ref1 = IDirectDrawSurface_Release(surface);
4720 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
4721 IDirect3DRM_Release(d3drm1);
4722 IDirectDraw_Release(ddraw);
4724}
#define IDirect3DRM_CreateDeviceFromSurface(p, a, b, c, d)
Definition: d3drm.h:125
#define IDirect3DRMDevice2_GetDirect3DDevice(p, a)
Definition: d3drmobj.h:575
#define DDERR_INVALIDCAPS
Definition: ddraw.h:77
#define DDSCAPS_SYSTEMMEMORY
Definition: ddraw.h:263

Referenced by START_TEST().

◆ test_create_device_from_surface2()

static void test_create_device_from_surface2 ( void  )
static

Definition at line 4726 of file d3drm.c.

4727{
4728 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4730 IDirectDraw *ddraw = NULL;
4731 IDirect3DRM *d3drm1 = NULL;
4732 IDirect3DRM2 *d3drm2 = NULL;
4733 IDirect3DRMDevice2 *device2 = (IDirect3DRMDevice2 *)0xdeadbeef;
4734 IDirect3DDevice2 *d3ddevice2 = NULL;
4735 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_surface = NULL, *d3drm_ds = NULL;
4736 DWORD expected_flags, ret_val;
4737 HWND window;
4738 GUID driver = IID_IDirect3DRGBDevice;
4739 ULONG ref1, ref2, ref3, surface_ref1, surface_ref2;
4740 RECT rc;
4741 BOOL use_sysmem_zbuffer = FALSE;
4742 HRESULT hr;
4743
4745 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4746
4748 GetClientRect(window, &rc);
4749
4750 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
4751 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
4752
4753 hr = Direct3DRMCreate(&d3drm1);
4754 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
4755 ref1 = get_refcount((IUnknown *)d3drm1);
4756
4757 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
4758 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
4759 ref2 = get_refcount((IUnknown *)d3drm2);
4760
4761 /* Create a surface and use it to create the retained mode device. */
4762 memset(&desc, 0, sizeof(desc));
4763 desc.dwSize = sizeof(desc);
4764 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4765 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
4766 desc.dwWidth = rc.right;
4767 desc.dwHeight = rc.bottom;
4768
4769 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4770 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4771
4772 hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, ddraw, surface, &device2);
4773 ok(hr == DDERR_INVALIDCAPS, "Expected hr == DDERR_INVALIDCAPS, got hr %#lx.\n", hr);
4774 ok(device2 == NULL, "Expected device returned == NULL, got %p.\n", device2);
4775 IDirectDrawSurface_Release(surface);
4776
4777 desc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
4778 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4779 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4780 surface_ref1 = get_refcount((IUnknown *)surface);
4781
4783 ok(hr == D3DRMERR_BADVALUE, "Expected hr == DDERR_BADVALUE, got hr %#lx.\n", hr);
4785 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr);
4786 hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, NULL, surface, &device2);
4787 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr);
4788
4789 hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, ddraw, surface, &device2);
4790 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr);
4791 ref3 = get_refcount((IUnknown *)d3drm1);
4792 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
4793 ref3 = get_refcount((IUnknown *)d3drm2);
4794 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4795 surface_ref2 = get_refcount((IUnknown *)surface);
4796 ok(surface_ref2 > surface_ref1, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n", surface_ref1, surface_ref2);
4797 ret_val = IDirect3DRMDevice2_GetWidth(device2);
4798 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
4799 ret_val = IDirect3DRMDevice2_GetHeight(device2);
4800 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
4801
4802 /* Check if CreateDeviceFromSurface creates a primary surface */
4803 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4804 NULL, &d3drm_surface, surface_callback);
4805 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
4806 ok(d3drm_surface == NULL, "No primary surface should have enumerated (%p).\n", d3drm_surface);
4807
4808 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4809 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4810
4811 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
4812 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4813 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
4814
4815 /* Check properties of attached depth surface */
4816 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &ds);
4817 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4818
4819 memset(&desc, 0, sizeof(desc));
4820 desc.dwSize = sizeof(desc);
4821 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
4822 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
4823
4824 use_sysmem_zbuffer = desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
4825 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
4826 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
4827 ok(desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER, "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
4829 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
4830
4831 IDirectDrawSurface_Release(ds);
4832 IDirect3DDevice2_Release(d3ddevice2);
4833 IDirectDrawSurface_Release(d3drm_surface);
4834
4836 ref3 = get_refcount((IUnknown *)d3drm1);
4837 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
4838 ref3 = get_refcount((IUnknown *)d3drm2);
4839 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4840 surface_ref2 = get_refcount((IUnknown *)surface);
4841 ok(surface_ref2 == surface_ref1, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n",
4842 surface_ref1, surface_ref2);
4843 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4844 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4845 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4846 ref1 = IDirectDrawSurface_Release(ds);
4847 ok(ref1 == 1, "Unexpected refcount %lu.\n", ref1);
4848
4849 ref1 = IDirectDrawSurface_Release(surface);
4850 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
4851
4852 memset(&desc, 0, sizeof(desc));
4853 desc.dwSize = sizeof(desc);
4854 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4855 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
4856 desc.dwWidth = rc.right;
4857 desc.dwHeight = rc.bottom;
4858
4859 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4860 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4861
4862 memset(&desc, 0, sizeof(desc));
4863 desc.dwSize = sizeof(desc);
4865 desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | (use_sysmem_zbuffer ? DDSCAPS_SYSTEMMEMORY : 0);
4866 desc.dwZBufferBitDepth = 16;
4867 desc.dwWidth = rc.right;
4868 desc.dwHeight = rc.bottom;
4869 hr = IDirectDraw_CreateSurface(ddraw, &desc, &ds, NULL);
4870 ok(hr == DD_OK, "Cannot create depth surface, hr %#lx.\n", hr);
4871 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
4872 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
4873
4874 hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, ddraw, surface, &device2);
4875 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr);
4876
4877 hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
4878 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4879
4880 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
4881 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4882 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
4883
4884 /* Check if depth surface matches the one we created */
4885 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &d3drm_ds);
4886 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4887 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
4888
4889 IDirectDrawSurface_Release(d3drm_ds);
4890 IDirectDrawSurface_Release(d3drm_surface);
4891 IDirectDrawSurface_Release(ds);
4892
4893 IDirect3DDevice2_Release(d3ddevice2);
4895 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
4896 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
4897 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4898 ref1 = IDirectDrawSurface_Release(ds);
4899 ok(ref1 == 1, "Unexpected refcount %lu.\n", ref1);
4900 ref1 = IDirectDrawSurface_Release(surface);
4901 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
4902 IDirect3DRM2_Release(d3drm2);
4903 IDirect3DRM_Release(d3drm1);
4904 IDirectDraw_Release(ddraw);
4906}
#define IDirect3DRM2_CreateDeviceFromSurface(p, a, b, c, d)
Definition: d3drm.h:266

Referenced by START_TEST().

◆ test_create_device_from_surface3()

static void test_create_device_from_surface3 ( void  )
static

Definition at line 4908 of file d3drm.c.

4909{
4910 DDSCAPS caps = { DDSCAPS_ZBUFFER };
4912 IDirectDraw *ddraw = NULL;
4913 IDirect3DRM *d3drm1 = NULL;
4914 IDirect3DRM3 *d3drm3 = NULL;
4915 IDirect3DRMDevice3 *device3 = (IDirect3DRMDevice3 *)0xdeadbeef;
4916 IDirect3DDevice2 *d3ddevice2 = NULL;
4917 IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_surface = NULL, *d3drm_ds = NULL;
4918 DWORD expected_flags, ret_val;
4919 HWND window;
4920 GUID driver = IID_IDirect3DRGBDevice;
4921 ULONG ref1, ref2, ref3, surface_ref1, surface_ref2;
4922 RECT rc;
4923 BOOL use_sysmem_zbuffer = FALSE;
4924 HRESULT hr;
4925
4927 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
4928
4930 GetClientRect(window, &rc);
4931
4932 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
4933 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
4934
4935 hr = Direct3DRMCreate(&d3drm1);
4936 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
4937 ref1 = get_refcount((IUnknown *)d3drm1);
4938
4939 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
4940 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
4941 ref2 = get_refcount((IUnknown *)d3drm3);
4942
4943 /* Create a surface and use it to create the retained mode device. */
4944 memset(&desc, 0, sizeof(desc));
4945 desc.dwSize = sizeof(desc);
4946 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
4947 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
4948 desc.dwWidth = rc.right;
4949 desc.dwHeight = rc.bottom;
4950
4951 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4952 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4953
4954 hr = IDirect3DRM3_CreateDeviceFromSurface(d3drm3, &driver, ddraw, surface, 0, &device3);
4955 ok(hr == DDERR_INVALIDCAPS, "Expected hr == DDERR_INVALIDCAPS, got hr %#lx.\n", hr);
4956 ok(device3 == NULL, "Expected device returned == NULL, got %p.\n", device3);
4957 IDirectDrawSurface_Release(surface);
4958
4959 desc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
4960 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
4961 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
4962 surface_ref1 = get_refcount((IUnknown *)surface);
4963
4964 hr = IDirect3DRM3_CreateDeviceFromSurface(d3drm3, &driver, ddraw, surface, 0, NULL);
4965 ok(hr == D3DRMERR_BADVALUE, "Expected hr == DDERR_BADVALUE, got hr %#lx.\n", hr);
4966 hr = IDirect3DRM3_CreateDeviceFromSurface(d3drm3, &driver, ddraw, NULL, 0, &device3);
4967 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr);
4968 hr = IDirect3DRM3_CreateDeviceFromSurface(d3drm3, &driver, NULL, surface, 0, &device3);
4969 ok(hr == D3DRMERR_BADDEVICE, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr);
4970
4971 hr = IDirect3DRM3_CreateDeviceFromSurface(d3drm3, &driver, ddraw, surface, 0, &device3);
4972 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
4973 ref3 = get_refcount((IUnknown *)d3drm1);
4974 ok(ref3 > ref1, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
4975 ref3 = get_refcount((IUnknown *)d3drm3);
4976 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
4977 surface_ref2 = get_refcount((IUnknown *)surface);
4978 ok(surface_ref2 > surface_ref1, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n", surface_ref1, surface_ref2);
4979 ret_val = IDirect3DRMDevice3_GetWidth(device3);
4980 ok(ret_val == rc.right, "Expected device width = 300, got %lu.\n", ret_val);
4981 ret_val = IDirect3DRMDevice3_GetHeight(device3);
4982 ok(ret_val == rc.bottom, "Expected device height == 200, got %lu.\n", ret_val);
4983
4984 /* Check if CreateDeviceFromSurface creates a primary surface */
4985 hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
4986 NULL, &d3drm_surface, surface_callback);
4987 ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
4988 ok(d3drm_surface == NULL, "No primary surface should have enumerated (%p).\n", d3drm_surface);
4989
4990 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
4991 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
4992
4993 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
4994 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
4995 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
4996
4997 /* Check properties of attached depth surface */
4998 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &ds);
4999 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5000
5001 memset(&desc, 0, sizeof(desc));
5002 desc.dwSize = sizeof(desc);
5003 hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
5004 ok(hr == DD_OK, "Cannot get z surface desc structure, hr %#lx.\n", hr);
5005
5006 use_sysmem_zbuffer = desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
5007 ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5008 rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
5009 ok(desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER, "Unexpected caps %lx.\n", desc.ddsCaps.dwCaps);
5011 ok(desc.dwFlags == expected_flags, "Expected %lx for flags, got %lx.\n", expected_flags, desc.dwFlags);
5012
5013 IDirectDrawSurface_Release(ds);
5014 IDirect3DDevice2_Release(d3ddevice2);
5015 IDirectDrawSurface_Release(d3drm_surface);
5017
5018 ref3 = get_refcount((IUnknown *)d3drm1);
5019 ok(ref1 == ref3, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
5020 ref3 = get_refcount((IUnknown *)d3drm3);
5021 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
5022 surface_ref2 = get_refcount((IUnknown *)surface);
5023 ok(surface_ref2 == surface_ref1, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n",
5024 surface_ref1, surface_ref2);
5025 /* In version 3, d3drm will destroy all references of the depth surface it created internally. */
5026 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
5027 todo_wine ok(hr == DDERR_NOTFOUND, "Expected hr == DDERR_NOTFOUND, got hr %#lx.\n", hr);
5028 if (SUCCEEDED(hr))
5029 IDirectDrawSurface_Release(ds);
5030 ref1 = IDirectDrawSurface_Release(surface);
5031 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
5032
5033 memset(&desc, 0, sizeof(desc));
5034 desc.dwSize = sizeof(desc);
5035 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
5036 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
5037 desc.dwWidth = rc.right;
5038 desc.dwHeight = rc.bottom;
5039
5040 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
5041 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
5042
5043 memset(&desc, 0, sizeof(desc));
5044 desc.dwSize = sizeof(desc);
5046 desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | (use_sysmem_zbuffer ? DDSCAPS_SYSTEMMEMORY : 0);
5047 desc.dwZBufferBitDepth = 16;
5048 desc.dwWidth = rc.right;
5049 desc.dwHeight = rc.bottom;
5050 hr = IDirectDraw_CreateSurface(ddraw, &desc, &ds, NULL);
5051 ok(hr == DD_OK, "Cannot create depth surface, hr %#lx.\n", hr);
5052 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
5053 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
5054
5056 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
5057
5058 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5059 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
5060
5061 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
5062 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
5063 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
5064
5065 /* Check if depth surface matches the one we created */
5066 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &d3drm_ds);
5067 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5068 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5069
5070 IDirectDrawSurface_Release(d3drm_ds);
5071 IDirectDrawSurface_Release(d3drm_surface);
5072 IDirectDrawSurface_Release(ds);
5073 IDirect3DDevice2_Release(d3ddevice2);
5075 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
5076 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5077 /* The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
5078 ref1 = IDirectDrawSurface_Release(ds);
5079 ok(ref1 == 1, "Unexpected refcount %lu.\n", ref1);
5080
5081 /* What happens if we pass no flags and still attach our own depth surface? */
5082 hr = IDirect3DRM3_CreateDeviceFromSurface(d3drm3, &driver, ddraw, surface, 0, &device3);
5083 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
5084
5085 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5086 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
5087
5088 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
5089 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
5090 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
5091
5092 /* Check if depth surface matches the one we created */
5093 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &d3drm_ds);
5094 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5095 ok(ds == d3drm_ds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, d3drm_ds);
5096
5097 IDirectDrawSurface_Release(d3drm_ds);
5098 IDirectDrawSurface_Release(d3drm_surface);
5099 IDirect3DDevice2_Release(d3ddevice2);
5101 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
5102 ok(hr == DD_OK, "Cannot get attached depth surface, hr %#lx.\n", hr);
5103 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
5104 ref1 = IDirectDrawSurface_Release(ds);
5105 ok(ref1 == 1, "Unexpected refcount %lu.\n", ref1);
5106 ref1 = IDirectDrawSurface_Release(surface);
5107 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
5108
5109 memset(&desc, 0, sizeof(desc));
5110 desc.dwSize = sizeof(desc);
5111 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
5112 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
5113 desc.dwWidth = rc.right;
5114 desc.dwHeight = rc.bottom;
5115
5116 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
5117 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
5118
5119 /* What happens if we don't pass D3DRMDEVICE_NOZBUFFER and still not attach our own depth surface? */
5121 ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
5122
5123 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2);
5124 ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
5125
5126 hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
5127 ok(hr == DD_OK, "Cannot get surface to the render target, hr %#lx.\n", hr);
5128 ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
5129
5130 /* Check if depth surface matches the one we created */
5131 hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &d3drm_ds);
5132 ok(hr == DDERR_NOTFOUND, "Expected hr == DDERR_NOTFOUND, got %#lx.\n", hr);
5133 IDirectDrawSurface_Release(d3drm_surface);
5134
5135 IDirect3DDevice2_Release(d3ddevice2);
5137 ref1 = IDirectDrawSurface_Release(surface);
5138 ok(!ref1, "Unexpected refcount %lu.\n", ref1);
5139 IDirect3DRM3_Release(d3drm3);
5140 IDirect3DRM_Release(d3drm1);
5141 IDirectDraw_Release(ddraw);
5143}
#define IDirect3DRM3_CreateDeviceFromSurface(p, a, b, c, d, e)
Definition: d3drm.h:414
#define D3DRMDEVICE_NOZBUFFER
Definition: d3drmdef.h:271
#define DDERR_NOTFOUND
Definition: ddraw.h:99

Referenced by START_TEST().

◆ test_create_texture_from_surface()

static void test_create_texture_from_surface ( void  )
static

Definition at line 7509 of file d3drm.c.

7510{
7511 D3DRMIMAGE testimg =
7512 {
7513 0, 0, 0, 0, 0,
7514 TRUE, 0, (void *)0xcafebabe, NULL,
7515 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
7516 };
7517 IDirectDrawSurface *surface = NULL, *surface2 = NULL, *ds = NULL;
7518 IDirect3DRMTexture *texture1;
7519 IDirect3DRMTexture2 *texture2;
7520 IDirect3DRMTexture3 *texture3;
7521 IDirectDraw *ddraw = NULL;
7522 IDirect3DRM *d3drm1 = NULL;
7523 IDirect3DRM2 *d3drm2 = NULL;
7524 IDirect3DRM3 *d3drm3 = NULL;
7525 ULONG ref1, ref2, ref3;
7528 HWND window;
7529 HRESULT hr;
7530 RECT rc;
7531
7533 ok(hr == DD_OK, "Cannot get IDirectDraw interface, hr %#lx.\n", hr);
7534
7536 GetClientRect(window, &rc);
7537
7538 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
7539 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
7540
7541 hr = Direct3DRMCreate(&d3drm1);
7542 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
7543
7544 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
7545 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
7546
7547 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
7548 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
7549
7550 /* Create a surface and use it to create a texture. */
7551 memset(&desc, 0, sizeof(desc));
7552 desc.dwSize = sizeof(desc);
7553 desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
7554 desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
7555 desc.dwWidth = rc.right;
7556 desc.dwHeight = rc.bottom;
7557
7558 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
7559 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
7560
7561 hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface2, NULL);
7562 ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
7563
7564 /* Test NULL params */
7565 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
7566 hr = IDirect3DRM_CreateTextureFromSurface(d3drm1, NULL, &texture1);
7567 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
7568 ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
7569
7571 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
7572
7573 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
7574 hr = IDirect3DRM2_CreateTextureFromSurface(d3drm2, NULL, &texture2);
7575 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
7576 ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
7577
7579 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
7580
7581 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
7582 hr = IDirect3DRM3_CreateTextureFromSurface(d3drm3, NULL, &texture3);
7583 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
7584 ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
7585
7587 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr);
7588
7589 ok(get_refcount((IUnknown *)surface) == 1, "Unexpected surface refcount.\n");
7590 hr = IDirect3DRM_CreateTextureFromSurface(d3drm1, surface, &texture1);
7591 ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
7592
7593 ok(get_refcount((IUnknown *)surface) == 2, "Unexpected surface refcount.\n");
7595 ok(image == NULL, "Unexpected image, %p.\n", image);
7597 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#lx.\n", hr);
7599
7600 ok(get_refcount((IUnknown *)surface) == 1, "Unexpected surface refcount.\n");
7601 hr = IDirect3DRM2_CreateTextureFromSurface(d3drm2, surface, &texture2);
7602 ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
7603 ok(get_refcount((IUnknown *)surface) == 2, "Unexpected surface refcount.\n");
7605 ok(image == NULL, "Unexpected image, %p.\n", image);
7607 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#lx.\n", hr);
7609
7610 ok(get_refcount((IUnknown *)surface) == 1, "Unexpected surface refcount.\n");
7611 hr = IDirect3DRM3_CreateTextureFromSurface(d3drm3, surface, &texture3);
7612 ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
7613 ok(get_refcount((IUnknown *)surface) == 2, "Unexpected surface refcount.\n");
7615 ok(image == NULL, "Unexpected image, %p.\n", image);
7617 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
7618 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, NULL);
7619 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr);
7620 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, &ds);
7621 ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
7622 ok(ds == surface, "Expected same surface back.\n");
7623 IDirectDrawSurface_Release(ds);
7624
7625 /* Init already initialized texture with same surface. */
7626 hr = IDirect3DRMTexture3_InitFromSurface(texture3, surface);
7627 ok(hr == D3DRMERR_BADOBJECT, "Expected a failure, hr %#lx.\n", hr);
7628
7629 /* Init already initialized texture with different surface. */
7630 hr = IDirect3DRMTexture3_InitFromSurface(texture3, surface2);
7631 ok(hr == D3DRMERR_BADOBJECT, "Expected a failure, hr %#lx.\n", hr);
7632
7633 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, &ds);
7634 ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
7635 ok(ds == surface, "Expected same surface back.\n");
7636 IDirectDrawSurface_Release(ds);
7637
7638 ref1 = get_refcount((IUnknown *)d3drm1);
7639 ref2 = get_refcount((IUnknown *)d3drm2);
7640 ref3 = get_refcount((IUnknown *)d3drm3);
7641 hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
7642 ok(hr == D3DRMERR_BADOBJECT, "Expected a failure, hr %#lx.\n", hr);
7643 ok(ref1 < get_refcount((IUnknown *)d3drm1), "Expected d3drm1 reference taken.\n");
7644 ok(ref2 == get_refcount((IUnknown *)d3drm2), "Expected d3drm2 reference unchanged.\n");
7645 ok(ref3 == get_refcount((IUnknown *)d3drm3), "Expected d3drm3 reference unchanged.\n");
7646 /* Release leaked reference to d3drm1 */
7647 IDirect3DRM_Release(d3drm1);
7648
7650
7651 /* Create from image, initialize from surface. */
7652 hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
7653 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr);
7654
7655 ref1 = get_refcount((IUnknown *)d3drm1);
7656 ref2 = get_refcount((IUnknown *)d3drm2);
7657 ref3 = get_refcount((IUnknown *)d3drm3);
7658 hr = IDirect3DRMTexture3_InitFromSurface(texture3, surface);
7659 ok(hr == D3DRMERR_BADOBJECT, "Expected a failure, hr %#lx.\n", hr);
7660 ok(ref1 < get_refcount((IUnknown *)d3drm1), "Expected d3drm1 reference taken.\n");
7661 ok(ref2 == get_refcount((IUnknown *)d3drm2), "Expected d3drm2 reference unchanged.\n");
7662 ok(ref3 == get_refcount((IUnknown *)d3drm3), "Expected d3drm3 reference unchanged.\n");
7663 /* Release leaked reference to d3drm1 */
7664 IDirect3DRM_Release(d3drm1);
7666
7667 IDirectDrawSurface_Release(surface2);
7668 IDirectDrawSurface_Release(surface);
7669 IDirect3DRM3_Release(d3drm3);
7670 IDirect3DRM2_Release(d3drm2);
7671 IDirect3DRM_Release(d3drm1);
7672 IDirectDraw_Release(ddraw);
7673}
#define IDirect3DRM_CreateTextureFromSurface(p, a, b)
Definition: d3drm.h:128
#define IDirect3DRM3_CreateTexture(p, a, b)
Definition: d3drm.h:409
#define IDirect3DRM2_CreateTextureFromSurface(p, a, b)
Definition: d3drm.h:269
#define IDirect3DRM3_CreateTextureFromSurface(p, a, b)
Definition: d3drm.h:417
#define IDirect3DRMTexture3_GetSurface(p, a, b)
Definition: d3drmobj.h:3509
#define IDirect3DRMTexture3_Release(p)
Definition: d3drmobj.h:3476
#define IDirect3DRMTexture3_InitFromImage(p, a)
Definition: d3drmobj.h:3506
#define IDirect3DRMTexture2_GetImage(p)
Definition: d3drmobj.h:3372
#define IDirect3DRMTexture3_GetImage(p)
Definition: d3drmobj.h:3500
#define IDirect3DRMTexture_InitFromSurface(p, a)
Definition: d3drmobj.h:3244
#define IDirect3DRMTexture3_InitFromSurface(p, a)
Definition: d3drmobj.h:3488
#define IDirect3DRMTexture_Release(p)
Definition: d3drmobj.h:3232
#define IDirect3DRMTexture_GetImage(p)
Definition: d3drmobj.h:3256
#define IDirect3DRMTexture2_InitFromSurface(p, a)
Definition: d3drmobj.h:3360
Definition: image.c:84

Referenced by START_TEST().

◆ test_d3drm_load()

static void test_d3drm_load ( void  )
static

Definition at line 3471 of file d3drm.c.

3472{
3473 HRESULT hr;
3474 IDirect3DRM *d3drm;
3476 const GUID* req_refiids[] = { &IID_IDirect3DRMMeshBuilder, &IID_IDirect3DRMFrame, &IID_IDirect3DRMMaterial };
3477
3479 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
3480
3481 info.lpMemory = data_d3drm_load;
3482 info.dSize = strlen(data_d3drm_load);
3483 hr = IDirect3DRM_Load(d3drm, &info, NULL, (GUID **)req_refiids, 3, D3DRMLOAD_FROMMEMORY,
3484 object_load_callback, (void *)0xdeadbeef, NULL, NULL, NULL);
3485 ok(hr == D3DRM_OK, "Cannot load data, hr %#lx\n", hr);
3486 ok(nb_objects == 3, "Should have loaded 3 objects (got %d)\n", nb_objects);
3487
3489}
#define IDirect3DRM_Load(p, a, b, c, d, e, f, g, h, i, j)
Definition: d3drm.h:143
#define D3DRMLOAD_FROMMEMORY
Definition: d3drmdef.h:343
static void __cdecl object_load_callback(IDirect3DRMObject *object, REFIID objectguid, void *arg)
Definition: d3drm.c:3463
static char data_d3drm_load[]
Definition: d3drm.c:359

Referenced by START_TEST().

◆ test_d3drm_qi()

static void test_d3drm_qi ( void  )
static

Definition at line 3677 of file d3drm.c.

3678{
3679 static const struct qi_test tests[] =
3680 {
3681 { &IID_IDirect3DRM3, &IID_IDirect3DRM3, &IID_IDirect3DRM3, S_OK },
3682 { &IID_IDirect3DRM2, &IID_IDirect3DRM2, &IID_IDirect3DRM2, S_OK },
3683 { &IID_IDirect3DRM, &IID_IDirect3DRM, &IID_IDirect3DRM, S_OK },
3684 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3685 { &IID_IDirect3DRMObject, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3686 { &IID_IDirect3DRMObject2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3687 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3688 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3689 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3690 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3691 { &IID_IDirect3DRMFrame, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3692 { &IID_IDirect3DRMFrame2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3693 { &IID_IDirect3DRMFrame3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3694 { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3695 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3696 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3697 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3698 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3699 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3700 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3701 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3702 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3703 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3704 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3705 { &IID_IDirect3DRMWrap, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3706 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3707 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3708 { &IID_IDirect3DRMAnimation, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3709 { &IID_IDirect3DRMAnimation2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3710 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3711 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3712 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3713 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3714 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3715 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3716 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3717 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3718 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3719 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3720 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3721 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3722 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3723 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3724 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3725 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3726 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3727 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3728 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3729 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3730 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3731 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3732 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3733 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3734 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3735 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3736 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3737 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3738 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3739 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3740 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3741 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3742 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3743 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3744 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3745 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3746 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3747 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3748 { &IID_IUnknown, &IID_IDirect3DRM, &IID_IDirect3DRM, S_OK },
3749 };
3750 HRESULT hr;
3751 IDirect3DRM *d3drm;
3752
3754 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
3755
3756 test_qi("d3drm_qi", (IUnknown *)d3drm, &IID_IDirect3DRM, tests, ARRAY_SIZE(tests));
3757
3759}

Referenced by START_TEST().

◆ test_destroy_callback()

static void test_destroy_callback ( unsigned int  test_idx,
REFCLSID  clsid,
REFIID  iid 
)
static

Definition at line 1498 of file d3drm.c.

1499{
1500 struct destroy_context context;
1501 IDirect3DRMObject *obj;
1503 IDirect3DRM *d3drm;
1504 HRESULT hr;
1505 int i;
1506
1508 ok(SUCCEEDED(hr), "Test %u: Cannot get IDirect3DRM interface, hr %#lx.\n", test_idx, hr);
1509
1510 hr = IDirect3DRM_CreateObject(d3drm, clsid, NULL, iid, (void **)&unknown);
1511 ok(hr == D3DRM_OK, "Test %u: Cannot get IDirect3DRMObject interface, hr %#lx.\n", test_idx, hr);
1512 hr = IUnknown_QueryInterface(unknown, &IID_IDirect3DRMObject, (void**)&obj);
1513 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1514 IUnknown_Release(unknown);
1515
1516 context.called = 0;
1517 context.test_idx = test_idx;
1518 context.obj = obj;
1519
1521 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected D3DRMERR_BADVALUE, hr %#lx.\n", test_idx, hr);
1522
1524 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1525 corder[2].callback = &destroy_callback;
1526 corder[2].context = &context;
1527
1528 /* same callback added twice */
1530 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1531 corder[1].callback = &destroy_callback;
1532 corder[1].context = &context;
1533
1535 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1536
1538 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1539
1540 /* add one more */
1542 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1543 corder[0].callback = &destroy_callback1;
1544 corder[0].context = &context;
1545
1547 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected D3DRM_BADVALUE, hr %#lx.\n", test_idx, hr);
1548
1549 context.called = 0;
1551 ok(context.called == 3, "Test %u: got %d, expected 3.\n", test_idx, context.called);
1552 for (i = 0; i < context.called; i++)
1553 {
1556 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder[i].callback,
1558 }
1559
1560 /* test this pattern - add cb1, add cb2, add cb1, delete cb1 */
1561 hr = IDirect3DRM_CreateObject(d3drm, clsid, NULL, iid, (void **)&unknown);
1562 ok(hr == D3DRM_OK, "Test %u: Cannot get IDirect3DRMObject interface, hr %#lx.\n", test_idx, hr);
1563 hr = IUnknown_QueryInterface(unknown, &IID_IDirect3DRMObject, (void**)&obj);
1564 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1565 IUnknown_Release(unknown);
1566
1568 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1569 corder[1].callback = &destroy_callback;
1570 corder[1].context = &context;
1571
1573 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1574 corder[0].callback = &destroy_callback1;
1575 corder[0].context = &context;
1576
1578 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1579
1581 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1582
1583 context.called = 0;
1584 hr = IDirect3DRMObject_QueryInterface(obj, &IID_IDirect3DRMObject, (void**)&context.obj);
1585 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx, hr);
1587 IUnknown_Release(unknown);
1588 ok(context.called == 2, "Test %u: got %d, expected 2.\n", test_idx, context.called);
1589 for (i = 0; i < context.called; i++)
1590 {
1593 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder[i].callback,
1595 }
1596
1598}
#define IDirect3DRMObject_DeleteDestroyCallback(p, a, b)
Definition: d3drmobj.h:224
#define IDirect3DRMObject_AddDestroyCallback(p, a, b)
Definition: d3drmobj.h:223
static IPrintDialogCallback callback
Definition: printdlg.c:325
struct callback_order corder[3]
const CLSID * clsid
Definition: msctf.cpp:50
unsigned int test_idx
Definition: d3drm.c:1470

Referenced by test_object().

◆ test_Device()

static void test_Device ( void  )
static

Definition at line 3143 of file d3drm.c.

3144{
3145 IDirectDrawClipper *pClipper;
3146 HRESULT hr;
3147 IDirect3DRM *d3drm;
3148 IDirect3DRMDevice *device;
3149 IDirect3DRMWinDevice *win_device;
3150 GUID driver;
3151 HWND window;
3152 RECT rc;
3153
3155 GetClientRect(window, &rc);
3156
3158 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
3159
3160 hr = DirectDrawCreateClipper(0, &pClipper, NULL);
3161 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface, hr %#lx\n", hr);
3162
3163 hr = IDirectDrawClipper_SetHWnd(pClipper, 0, window);
3164 ok(hr == DD_OK, "Cannot set HWnd to Clipper, hr %#lx\n", hr);
3165
3166 memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
3168 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr);
3169
3170 test_class_name((IDirect3DRMObject *)device, "Device");
3171 test_object_name((IDirect3DRMObject *)device);
3172
3173 /* WinDevice */
3174 if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMWinDevice, (void **)&win_device)))
3175 {
3176 win_skip("Cannot get IDirect3DRMWinDevice interface, hr %#lx, skipping tests\n", hr);
3177 goto cleanup;
3178 }
3179
3180 test_class_name((IDirect3DRMObject *)win_device, "Device");
3181 test_object_name((IDirect3DRMObject *)win_device);
3182 IDirect3DRMWinDevice_Release(win_device);
3183
3184cleanup:
3186 IDirectDrawClipper_Release(pClipper);
3187
3190}
#define IDirect3DRMWinDevice_Release(p)
Definition: d3drmwin.h:67
static void cleanup(void)
Definition: main.c:1335
#define test_object_name(a)
Definition: d3drm.c:213

Referenced by START_TEST().

◆ test_device_qi()

static void test_device_qi ( void  )
static

Definition at line 3878 of file d3drm.c.

3879{
3880 static const struct qi_test tests[] =
3881 {
3882 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3883 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3884 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3885 { &IID_IDirect3DRMDevice, &IID_IUnknown, &IID_IDirect3DRMDevice, S_OK, },
3886 { &IID_IDirect3DRMDevice2, &IID_IUnknown, &IID_IDirect3DRMDevice2, S_OK, },
3887 { &IID_IDirect3DRMDevice3, &IID_IUnknown, &IID_IDirect3DRMDevice3, S_OK, },
3888 { &IID_IDirect3DRMWinDevice, &IID_IUnknown, &IID_IDirect3DRMWinDevice, S_OK, },
3889 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMDevice, S_OK, },
3890 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3891 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3892 { &IID_IDirect3DRMFrame, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3893 { &IID_IDirect3DRMFrame2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3894 { &IID_IDirect3DRMFrame3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3895 { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3896 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3897 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3898 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3899 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3900 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3901 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3902 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3903 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3904 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3905 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3906 { &IID_IDirect3DRMWrap, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3907 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3908 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3909 { &IID_IDirect3DRMAnimation, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3910 { &IID_IDirect3DRMAnimation2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3911 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3912 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3913 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3914 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3915 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3916 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3917 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3918 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3919 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3920 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3921 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3922 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3923 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3924 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3925 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3926 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3927 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3928 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3929 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3930 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3931 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3932 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3933 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3934 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3935 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3936 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3937 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3938 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3939 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3940 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3941 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3942 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3943 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3944 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3945 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3946 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3947 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3948 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3950 };
3951 HRESULT hr;
3952 IDirect3DRM *d3drm1;
3953 IDirect3DRM2 *d3drm2;
3954 IDirect3DRM3 *d3drm3;
3955 IDirectDrawClipper *clipper;
3956 IDirect3DRMDevice *device1;
3957 IDirect3DRMDevice2 *device2;
3958 IDirect3DRMDevice3 *device3;
3960 HWND window;
3961 GUID driver;
3962 RECT rc;
3963
3965 GetClientRect(window, &rc);
3966 hr = DirectDrawCreateClipper(0, &clipper, NULL);
3967 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface, hr %#lx\n", hr);
3968 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
3969 ok(hr == DD_OK, "Cannot set HWnd to Clipper, hr %#lx\n", hr);
3970
3971 hr = Direct3DRMCreate(&d3drm1);
3972 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
3973 memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
3974 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1);
3975 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr);
3977 ok(SUCCEEDED(hr), "Cannot get IUnknown interface from IDirect3DRMDevice, hr %#lx\n", hr);
3979 test_qi("device1_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
3980 IUnknown_Release(unknown);
3981
3982 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
3983 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
3984 hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, rc.right, rc.bottom, &device2);
3985 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 interface, hr %#lx\n", hr);
3987 ok(SUCCEEDED(hr), "Cannot get IUnknown interface from IDirect3DRMDevice2, hr %#lx\n", hr);
3989 test_qi("device2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
3990 IUnknown_Release(unknown);
3991
3992 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
3993 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
3994 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
3995 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr);
3997 ok(SUCCEEDED(hr), "Cannot get IUnknown interface from IDirect3DRMDevice3, hr %#lx\n", hr);
3999 test_qi("device3_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
4000 IUnknown_Release(unknown);
4001
4002 IDirectDrawClipper_Release(clipper);
4003 IDirect3DRM3_Release(d3drm3);
4004 IDirect3DRM2_Release(d3drm2);
4005 IDirect3DRM_Release(d3drm1);
4007}

Referenced by START_TEST().

◆ test_Face()

static void test_Face ( void  )
static

Definition at line 846 of file d3drm.c.

847{
848 HRESULT hr;
849 IDirect3DRM *d3drm;
850 IDirect3DRM2 *d3drm2;
851 IDirect3DRM3 *d3drm3;
852 IDirect3DRMMeshBuilder2 *MeshBuilder2;
853 IDirect3DRMMeshBuilder3 *MeshBuilder3;
854 IDirect3DRMFace *face1;
855 IDirect3DRMObject *obj;
856 IDirect3DRMFace2 *face2;
857 IDirect3DRMFaceArray *array1;
859 D3DVECTOR v1[4], n1[4], v2[4], n2[4];
861 DWORD count;
862 int icount;
864
866 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
867
869 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface, hr %#lx\n", hr);
870 if (FAILED(hr))
871 {
872 skip("Cannot get IDirect3DRMFace interface, hr %#lx, skipping tests\n", hr);
874 return;
875 }
876
877 hr = IDirect3DRMFace_QueryInterface(face1, &IID_IDirect3DRMObject, (void **)&obj);
878 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
879 ok(obj == (IDirect3DRMObject *)face1, "Unexpected interface pointer.\n");
881
882 test_class_name((IDirect3DRMObject *)face1, "Face");
883 test_object_name((IDirect3DRMObject *)face1);
884
885 icount = IDirect3DRMFace_GetVertexCount(face1);
886 ok(!icount, "wrong VertexCount: %i\n", icount);
887
889
890 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM2, (void **)&d3drm2)))
891 {
892 win_skip("Cannot get IDirect3DRM2 interface, hr %#lx, skipping tests\n", hr);
894 return;
895 }
896
897 hr = IDirect3DRM2_CreateMeshBuilder(d3drm2, &MeshBuilder2);
898 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder2 interface, hr %#lx\n", hr);
899
900 icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2);
901 ok(!icount, "wrong FaceCount: %i\n", icount);
902
903 array1 = NULL;
904 hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1);
906 ok(hr == D3DRM_OK, "Cannot get FaceArray, hr %#lx\n", hr);
907
908 hr = IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2, &face1);
909 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface, hr %#lx\n", hr);
910
911 icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2);
913 ok(icount == 1, "wrong FaceCount: %i\n", icount);
914
915 array1 = NULL;
916 hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1);
918 ok(hr == D3DRM_OK, "Cannot get FaceArray, hr %#lx\n", hr);
920 ok(array1 != NULL, "pArray = %p\n", array1);
921 if (array1)
922 {
923 IDirect3DRMFace *face;
925 ok(count == 1, "count = %lu\n", count);
927 ok(hr == D3DRM_OK, "Cannot get face, hr %#lx\n", hr);
930 }
931
932 icount = IDirect3DRMFace_GetVertexCount(face1);
933 ok(!icount, "wrong VertexCount: %i\n", icount);
934
936 ok(quality == D3DRMRENDER_GOURAUD, "Unexpected %lx.\n", quality);
937
939 ok(hr == S_OK, "got %lx.\n", hr);
940
942 ok(quality == D3DRMRENDER_PHONG, "got %lx.\n", quality);
943
945 ok(hr == S_OK, "got %lx.\n", hr);
946
949
950 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
951 {
952 win_skip("Cannot get IDirect3DRM3 interface, hr %#lx, skipping tests\n", hr);
954 return;
955 }
956
957 hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &MeshBuilder3);
958 ok(hr == D3DRM_OK, "Unexpected hr %lx.\n", hr);
959
960 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
961 ok(!icount, "wrong FaceCount: %i\n", icount);
962
963 hr = IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3, &face2);
964 ok(hr == D3DRM_OK, "Unexpected hr %lx.\n", hr);
965
966 hr = IDirect3DRMFace2_QueryInterface(face2, &IID_IDirect3DRMObject, (void **)&obj);
967 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
968
969 hr = IDirect3DRMFace2_QueryInterface(face2, &IID_IDirect3DRMFace, (void **)&face1);
970 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
971 ok(obj == (IDirect3DRMObject *)face1, "Unexpected interface pointer.\n");
972
975
976 test_class_name((IDirect3DRMObject *)face2, "Face");
977 test_object_name((IDirect3DRMObject *)face2);
978
979 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
981 ok(icount == 1, "wrong FaceCount: %i\n", icount);
982
983 array1 = NULL;
984 hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1);
986 ok(hr == D3DRM_OK, "Cannot get FaceArray, hr %#lx\n", hr);
988 ok(array1 != NULL, "pArray = %p\n", array1);
989 if (array1)
990 {
991 IDirect3DRMFace *face;
993 ok(count == 1, "count = %lu\n", count);
995 ok(hr == D3DRM_OK, "Cannot get face, hr %#lx\n", hr);
998 }
999
1000 icount = IDirect3DRMFace2_GetVertexCount(face2);
1001 ok(!icount, "wrong VertexCount: %i\n", icount);
1002
1003 info.lpMemory = data_ok;
1004 info.dSize = strlen(data_ok);
1006 ok(hr == D3DRM_OK, "Cannot load mesh data, hr %#lx\n", hr);
1007
1008 icount = IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3);
1009 ok(icount == 4, "Wrong number of vertices %d (must be 4)\n", icount);
1010
1011 icount = IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3);
1012 ok(icount == 4, "Wrong number of normals %d (must be 4)\n", icount);
1013
1014 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
1015 todo_wine
1016 ok(icount == 4, "Wrong number of faces %d (must be 4)\n", icount);
1017
1018 count = 4;
1019 hr = IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3, 0, &count, v1);
1020 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
1021 ok(count == 4, "Wrong number of vertices %ld (must be 4)\n", count);
1022
1023 hr = IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3, 0, &count, n1);
1024 ok(hr == D3DRM_OK, "Cannot get normals information, hr %#lx\n", hr);
1025 ok(count == 4, "Wrong number of normals %ld (must be 4)\n", count);
1026
1027 array1 = NULL;
1028 hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1);
1029 todo_wine
1030 ok(hr == D3DRM_OK, "Cannot get FaceArray, hr %#lx\n", hr);
1031 todo_wine
1032 ok(array1 != NULL, "pArray = %p\n", array1);
1033 if (array1)
1034 {
1035 IDirect3DRMFace *face;
1037 ok(count == 4, "count = %lu\n", count);
1039 ok(hr == D3DRM_OK, "Cannot get face, hr %#lx\n", hr);
1041 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
1042 ok(count == 3, "Wrong number of vertices %ld (must be 3)\n", count);
1043
1044 vector_eq(&v1[0], &v2[0]);
1045 vector_eq(&v1[1], &v2[1]);
1046 vector_eq(&v1[2], &v2[2]);
1047
1048 vector_eq(&n1[0], &n2[0]);
1049 vector_eq(&n1[1], &n2[1]);
1050 vector_eq(&n1[2], &n2[2]);
1051
1054 }
1055
1056 /* Setting face color. */
1057 hr = IDirect3DRMFace2_SetColor(face2, 0x1f180587);
1058 ok(SUCCEEDED(hr), "Failed to set face color, hr %#lx.\n", hr);
1060 ok(color == 0x1f180587, "Unexpected color %8lx.\n", color);
1061
1062 hr = IDirect3DRMFace2_SetColorRGB(face2, 0.5f, 0.5f, 0.5f);
1063 ok(SUCCEEDED(hr), "Failed to set color, hr %#lx.\n", hr);
1065 ok(color == 0xff7f7f7f, "Unexpected color %8lx.\n", color);
1066
1068 IDirect3DRMMeshBuilder3_Release(MeshBuilder3);
1069 IDirect3DRM3_Release(d3drm3);
1070 IDirect3DRM2_Release(d3drm2);
1072}
#define skip(...)
Definition: atltest.h:64
#define IDirect3DRM_CreateFace(p, a)
Definition: d3drm.h:117
#define IDirect3DRM2_CreateMeshBuilder(p, a)
Definition: d3drm.h:257
#define IDirect3DRM3_CreateMeshBuilder(p, a)
Definition: d3drm.h:405
#define D3DRMRENDER_GOURAUD
Definition: d3drmdef.h:94
#define D3DRMRENDER_PHONG
Definition: d3drmdef.h:95
DWORD D3DRMRENDERQUALITY
Definition: d3drmdef.h:89
#define IDirect3DRMMeshBuilder3_SetQuality(p, a)
Definition: d3drmobj.h:2957
#define IDirect3DRMMeshBuilder3_GetNormals(p, a, b, c)
Definition: d3drmobj.h:2996
#define IDirect3DRMFaceArray_GetSize(p)
Definition: d3drmobj.h:4497
#define IDirect3DRMFace_Release(p)
Definition: d3drmobj.h:2310
#define IDirect3DRMMeshBuilder3_GetVertices(p, a, b, c)
Definition: d3drmobj.h:2994
#define IDirect3DRMMeshBuilder3_CreateFace(p, a)
Definition: d3drmobj.h:2970
#define IDirect3DRMFace_QueryInterface(p, a, b)
Definition: d3drmobj.h:2308
#define IDirect3DRMMeshBuilder3_GetQuality(p)
Definition: d3drmobj.h:2971
#define IDirect3DRMFace2_QueryInterface(p, a, b)
Definition: d3drmobj.h:2418
#define IDirect3DRMMeshBuilder3_GetFaces(p, a)
Definition: d3drmobj.h:2964
#define IDirect3DRMMeshBuilder3_Load(p, a, b, c, d, e)
Definition: d3drmobj.h:2938
#define IDirect3DRMMeshBuilder2_GetFaces(p, a)
Definition: d3drmobj.h:2764
#define IDirect3DRMFace2_GetColor(p)
Definition: d3drmobj.h:2448
#define IDirect3DRMMeshBuilder2_GetFaceCount(p)
Definition: d3drmobj.h:2772
#define IDirect3DRMMeshBuilder3_GetNormalCount(p)
Definition: d3drmobj.h:2997
#define IDirect3DRMMeshBuilder3_Release(p)
Definition: d3drmobj.h:2926
#define IDirect3DRMFace2_SetColorRGB(p, a, b, c)
Definition: d3drmobj.h:2433
#define IDirect3DRMFace_GetVertexCount(p)
Definition: d3drmobj.h:2335
#define IDirect3DRMFace2_GetVertexCount(p)
Definition: d3drmobj.h:2445
#define IDirect3DRMFace2_Release(p)
Definition: d3drmobj.h:2420
#define IDirect3DRMFaceArray_Release(p)
Definition: d3drmobj.h:4495
#define IDirect3DRMMeshBuilder3_GetVertexCount(p)
Definition: d3drmobj.h:2975
#define IDirect3DRMFace2_SetColor(p, a)
Definition: d3drmobj.h:2434
#define IDirect3DRMMeshBuilder2_CreateFace(p, a)
Definition: d3drmobj.h:2769
#define IDirect3DRMFace_GetVertices(p, a, b, c)
Definition: d3drmobj.h:2330
#define IDirect3DRMFaceArray_GetElement(p, a, b)
Definition: d3drmobj.h:4499
#define IDirect3DRMMeshBuilder2_Release(p)
Definition: d3drmobj.h:2727
#define IDirect3DRMMeshBuilder3_GetFaceCount(p)
Definition: d3drmobj.h:2974
WORD face[3]
Definition: mesh.c:4854
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
int quality
Definition: jpeglib.h:994
#define vector_eq(a, b)
Definition: d3drm.c:104
static char data_ok[]
Definition: d3drm.c:302
int n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147

Referenced by START_TEST().

◆ test_Frame()

static void test_Frame ( void  )
static

Definition at line 1074 of file d3drm.c.

1075{
1076 HRESULT hr;
1077 IDirect3DRM *d3drm;
1078 IDirect3DRMFrame *pFrameC;
1079 IDirect3DRMFrame *pFrameP1;
1080 IDirect3DRMFrame *pFrameP2;
1081 IDirect3DRMFrame *pFrameTmp;
1082 IDirect3DRMFrame *scene_frame;
1083 IDirect3DRMFrameArray *frame_array;
1084 IDirect3DRMMeshBuilder *mesh_builder;
1085 IDirect3DRMVisual *visual1;
1086 IDirect3DRMVisual *visual_tmp;
1087 IDirect3DRMVisualArray *visual_array;
1088 IDirect3DRMLight *light1;
1089 IDirect3DRMLight *light_tmp;
1090 IDirect3DRMLightArray *light_array;
1091 IDirect3DRMFrame3 *frame3;
1093 ULONG ref, ref2;
1095
1097 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
1098
1100 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameC);
1101 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
1102 CHECK_REFCOUNT(pFrameC, 1);
1103 ref2 = get_refcount((IUnknown *)d3drm);
1104 ok(ref2 > ref, "Expected d3drm object to be referenced.\n");
1105
1106 test_class_name((IDirect3DRMObject *)pFrameC, "Frame");
1107 test_object_name((IDirect3DRMObject *)pFrameC);
1108
1110 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr);
1111 pFrameTmp = (void*)0xdeadbeef;
1112 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1113 ok(hr == D3DRM_OK, "Cannot get parent frame, hr %#lx\n", hr);
1114 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1115 CHECK_REFCOUNT(pFrameC, 1);
1116
1117 frame_array = NULL;
1118 hr = IDirect3DRMFrame_GetChildren(pFrameC, &frame_array);
1119 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1120 ok(!!frame_array, "frame_array = %p\n", frame_array);
1121 if (frame_array)
1122 {
1123 count = IDirect3DRMFrameArray_GetSize(frame_array);
1124 ok(count == 0, "count = %lu\n", count);
1125 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1126 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr);
1127 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1128 IDirect3DRMFrameArray_Release(frame_array);
1129 }
1130
1131 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP1);
1132 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
1133
1134 /* GetParent with NULL pointer */
1135 hr = IDirect3DRMFrame_GetParent(pFrameP1, NULL);
1136 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr);
1137 CHECK_REFCOUNT(pFrameP1, 1);
1138
1139 /* [Add/Delete]Child with NULL pointer */
1140 hr = IDirect3DRMFrame_AddChild(pFrameP1, NULL);
1141 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr);
1142 CHECK_REFCOUNT(pFrameP1, 1);
1143
1145 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr);
1146 CHECK_REFCOUNT(pFrameP1, 1);
1147
1148 /* Add child to first parent */
1149 pFrameTmp = (void*)0xdeadbeef;
1150 hr = IDirect3DRMFrame_GetParent(pFrameP1, &pFrameTmp);
1151 ok(hr == D3DRM_OK, "Cannot get parent frame, hr %#lx\n", hr);
1152 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1153
1154 hr = IDirect3DRMFrame_AddChild(pFrameP1, pFrameC);
1155 ok(hr == D3DRM_OK, "Cannot add child frame, hr %#lx\n", hr);
1156 CHECK_REFCOUNT(pFrameP1, 1);
1157 CHECK_REFCOUNT(pFrameC, 2);
1158
1159 hr = IDirect3DRMFrame_GetScene(pFrameC, NULL);
1160 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1161 hr = IDirect3DRMFrame_GetScene(pFrameC, &scene_frame);
1162 ok(SUCCEEDED(hr), "Cannot get scene, hr %#lx.\n", hr);
1163 ok(scene_frame == pFrameP1, "Expected scene frame == %p, got %p.\n", pFrameP1, scene_frame);
1164 CHECK_REFCOUNT(pFrameP1, 2);
1165 IDirect3DRMFrame_Release(scene_frame);
1166 hr = IDirect3DRMFrame_GetScene(pFrameP1, &scene_frame);
1167 ok(SUCCEEDED(hr), "Cannot get scene, hr %#lx.\n", hr);
1168 ok(scene_frame == pFrameP1, "Expected scene frame == %p, got %p.\n", pFrameP1, scene_frame);
1169 CHECK_REFCOUNT(pFrameP1, 2);
1170 IDirect3DRMFrame_Release(scene_frame);
1171
1172 frame_array = NULL;
1173 hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array);
1174 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1175 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
1176 ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2),
1177 "Invalid refcount. Expected 3 (or 2) got %ld\n", get_refcount((IUnknown*)pFrameC));
1178 if (frame_array)
1179 {
1180 count = IDirect3DRMFrameArray_GetSize(frame_array);
1181 ok(count == 1, "count = %lu\n", count);
1182 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1183 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1184 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1185 ok((get_refcount((IUnknown*)pFrameC) == 4) || broken(get_refcount((IUnknown*)pFrameC) == 3),
1186 "Invalid refcount. Expected 4 (or 3) got %ld\n", get_refcount((IUnknown*)pFrameC));
1187 IDirect3DRMFrame_Release(pFrameTmp);
1188 ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2),
1189 "Invalid refcount. Expected 3 (or 2) got %ld\n", get_refcount((IUnknown*)pFrameC));
1190 IDirect3DRMFrameArray_Release(frame_array);
1191 CHECK_REFCOUNT(pFrameC, 2);
1192 }
1193
1194 pFrameTmp = (void*)0xdeadbeef;
1195 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1196 ok(hr == D3DRM_OK, "Cannot get parent frame, hr %#lx\n", hr);
1197 ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
1198 CHECK_REFCOUNT(pFrameP1, 2);
1199 IDirect3DRMFrame_Release(pFrameTmp);
1200 CHECK_REFCOUNT(pFrameP1, 1);
1201
1202 /* Add child to second parent */
1203 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP2);
1204 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
1205
1206 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1207 ok(hr == D3DRM_OK, "Cannot add child frame, hr %#lx\n", hr);
1208 CHECK_REFCOUNT(pFrameC, 2);
1209
1210 frame_array = NULL;
1211 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1212 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1213 if (frame_array)
1214 {
1215 count = IDirect3DRMFrameArray_GetSize(frame_array);
1216 ok(count == 1, "count = %lu\n", count);
1217 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1218 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1219 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1220 IDirect3DRMFrame_Release(pFrameTmp);
1221 IDirect3DRMFrameArray_Release(frame_array);
1222 }
1223
1224 frame_array = NULL;
1225 hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array);
1226 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1227 if (frame_array)
1228 {
1229 count = IDirect3DRMFrameArray_GetSize(frame_array);
1230 ok(count == 0, "count = %lu\n", count);
1231 pFrameTmp = (void*)0xdeadbeef;
1232 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1233 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr);
1234 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1235 IDirect3DRMFrameArray_Release(frame_array);
1236 }
1237 hr = IDirect3DRMFrame_GetScene(pFrameC, &scene_frame);
1238 ok(SUCCEEDED(hr), "Cannot get scene, hr %#lx.\n", hr);
1239 ok(scene_frame == pFrameP2, "Expected scene frame == %p, got %p.\n", pFrameP2, scene_frame);
1240 CHECK_REFCOUNT(pFrameP2, 2);
1241 IDirect3DRMFrame_Release(scene_frame);
1242 hr = IDirect3DRMFrame_GetScene(pFrameP2, &scene_frame);
1243 ok(SUCCEEDED(hr), "Cannot get scene, hr %#lx.\n", hr);
1244 ok(scene_frame == pFrameP2, "Expected scene frame == %p, got %p.\n", pFrameP2, scene_frame);
1245 CHECK_REFCOUNT(pFrameP2, 2);
1246 IDirect3DRMFrame_Release(scene_frame);
1247
1248 pFrameTmp = (void*)0xdeadbeef;
1249 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1250 ok(hr == D3DRM_OK, "Cannot get parent frame, hr %#lx\n", hr);
1251 ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp);
1252 CHECK_REFCOUNT(pFrameP2, 2);
1253 CHECK_REFCOUNT(pFrameC, 2);
1254 IDirect3DRMFrame_Release(pFrameTmp);
1255 CHECK_REFCOUNT(pFrameP2, 1);
1256
1257 /* Add child again */
1258 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1259 ok(hr == D3DRM_OK, "Cannot add child frame, hr %#lx\n", hr);
1260 CHECK_REFCOUNT(pFrameC, 2);
1261
1262 frame_array = NULL;
1263 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1264 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1265 if (frame_array)
1266 {
1267 count = IDirect3DRMFrameArray_GetSize(frame_array);
1268 ok(count == 1, "count = %lu\n", count);
1269 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1270 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1271 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1272 IDirect3DRMFrame_Release(pFrameTmp);
1273 IDirect3DRMFrameArray_Release(frame_array);
1274 }
1275
1276 /* Delete child */
1277 hr = IDirect3DRMFrame_DeleteChild(pFrameP2, pFrameC);
1278 ok(hr == D3DRM_OK, "Cannot delete child frame, hr %#lx\n", hr);
1279 CHECK_REFCOUNT(pFrameC, 1);
1280
1281 frame_array = NULL;
1282 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1283 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1284 if (frame_array)
1285 {
1286 count = IDirect3DRMFrameArray_GetSize(frame_array);
1287 ok(count == 0, "count = %lu\n", count);
1288 pFrameTmp = (void*)0xdeadbeef;
1289 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1290 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr);
1291 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1292 IDirect3DRMFrameArray_Release(frame_array);
1293 }
1294
1295 pFrameTmp = (void*)0xdeadbeef;
1296 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1297 ok(hr == D3DRM_OK, "Cannot get parent frame, hr %#lx\n", hr);
1298 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1299
1300 /* Add two children */
1301 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1302 ok(hr == D3DRM_OK, "Cannot add child frame, hr %#lx\n", hr);
1303 CHECK_REFCOUNT(pFrameC, 2);
1304
1305 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameP1);
1306 ok(hr == D3DRM_OK, "Cannot add child frame, hr %#lx\n", hr);
1307 CHECK_REFCOUNT(pFrameP1, 2);
1308
1309 frame_array = NULL;
1310 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1311 ok(hr == D3DRM_OK, "Cannot get children, hr %#lx\n", hr);
1312 if (frame_array)
1313 {
1314 count = IDirect3DRMFrameArray_GetSize(frame_array);
1315 ok(count == 2, "count = %lu\n", count);
1316 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1317 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1318 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1319 IDirect3DRMFrame_Release(pFrameTmp);
1320 hr = IDirect3DRMFrameArray_GetElement(frame_array, 1, &pFrameTmp);
1321 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1322 ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
1323 IDirect3DRMFrame_Release(pFrameTmp);
1324 IDirect3DRMFrameArray_Release(frame_array);
1325 }
1326
1327 /* [Add/Delete]Visual with NULL pointer */
1328 hr = IDirect3DRMFrame_AddVisual(pFrameP1, NULL);
1329 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr);
1330 CHECK_REFCOUNT(pFrameP1, 2);
1331
1333 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr);
1334 CHECK_REFCOUNT(pFrameP1, 2);
1335
1336 /* Create Visual */
1338 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface, hr %#lx\n", hr);
1339 visual1 = (IDirect3DRMVisual *)mesh_builder;
1340
1341 /* Add Visual to first parent */
1342 hr = IDirect3DRMFrame_AddVisual(pFrameP1, visual1);
1343 ok(hr == D3DRM_OK, "Cannot add visual, hr %#lx\n", hr);
1344 CHECK_REFCOUNT(pFrameP1, 2);
1345 CHECK_REFCOUNT(visual1, 2);
1346
1347 visual_array = NULL;
1348 hr = IDirect3DRMFrame_GetVisuals(pFrameP1, &visual_array);
1349 ok(hr == D3DRM_OK, "Cannot get visuals, hr %#lx\n", hr);
1350 if (visual_array)
1351 {
1352 count = IDirect3DRMVisualArray_GetSize(visual_array);
1353 ok(count == 1, "count = %lu\n", count);
1354 hr = IDirect3DRMVisualArray_GetElement(visual_array, 0, &visual_tmp);
1355 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1356 ok(visual_tmp == visual1, "visual_tmp = %p\n", visual_tmp);
1357 IDirect3DRMVisual_Release(visual_tmp);
1358 IDirect3DRMVisualArray_Release(visual_array);
1359 }
1360
1361 /* Delete Visual */
1362 hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, visual1);
1363 ok(hr == D3DRM_OK, "Cannot delete visual, hr %#lx\n", hr);
1364 CHECK_REFCOUNT(pFrameP1, 2);
1366
1367 /* [Add/Delete]Light with NULL pointer */
1368 hr = IDirect3DRMFrame_AddLight(pFrameP1, NULL);
1369 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr);
1370 CHECK_REFCOUNT(pFrameP1, 2);
1371
1373 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr);
1374 CHECK_REFCOUNT(pFrameP1, 2);
1375
1376 /* Create Light */
1377 hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.1, 0.2, 0.3, &light1);
1378 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface, hr %#lx\n", hr);
1379
1380 /* Add Light to first parent */
1381 hr = IDirect3DRMFrame_AddLight(pFrameP1, light1);
1382 ok(hr == D3DRM_OK, "Cannot add light, hr %#lx\n", hr);
1383 CHECK_REFCOUNT(pFrameP1, 2);
1384 CHECK_REFCOUNT(light1, 2);
1385
1386 light_array = NULL;
1387 hr = IDirect3DRMFrame_GetLights(pFrameP1, &light_array);
1388 ok(hr == D3DRM_OK, "Cannot get lights, hr %#lx\n", hr);
1389 if (light_array)
1390 {
1391 count = IDirect3DRMLightArray_GetSize(light_array);
1392 ok(count == 1, "count = %lu\n", count);
1393 hr = IDirect3DRMLightArray_GetElement(light_array, 0, &light_tmp);
1394 ok(hr == D3DRM_OK, "Cannot get element, hr %#lx\n", hr);
1395 ok(light_tmp == light1, "light_tmp = %p\n", light_tmp);
1396 IDirect3DRMLight_Release(light_tmp);
1397 IDirect3DRMLightArray_Release(light_array);
1398 }
1399
1400 /* Delete Light */
1401 hr = IDirect3DRMFrame_DeleteLight(pFrameP1, light1);
1402 ok(hr == D3DRM_OK, "Cannot delete light, hr %#lx\n", hr);
1403 CHECK_REFCOUNT(pFrameP1, 2);
1405
1406 /* Test SceneBackground on first parent */
1408 ok(color == 0xff000000, "wrong color %lx.\n", color);
1409
1410 hr = IDirect3DRMFrame_SetSceneBackground(pFrameP1, 0xff180587);
1411 ok(hr == D3DRM_OK, "Cannot set color, hr %#lx\n", hr);
1413 ok(color == 0xff180587, "wrong color %lx.\n", color);
1414
1415 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1, 0.5, 0.5, 0.5);
1416 ok(hr == D3DRM_OK, "Cannot set color, hr %#lx\n", hr);
1418 ok(color == 0xff7f7f7f, "wrong color %lx.\n", color);
1419
1420 /* Traversal options. */
1421 hr = IDirect3DRMFrame_QueryInterface(pFrameP2, &IID_IDirect3DRMFrame3, (void **)&frame3);
1422 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMFrame3 interface, hr %#lx.\n", hr);
1423
1425 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1426
1427 options = 0;
1429 ok(SUCCEEDED(hr), "Failed to get traversal options, hr %#lx.\n", hr);
1430 ok(options == (D3DRMFRAME_RENDERENABLE | D3DRMFRAME_PICKENABLE), "Unexpected default options %#lx.\n", options);
1431
1433 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
1434
1435 hr = IDirect3DRMFrame3_SetTraversalOptions(frame3, 0xf0000000);
1436 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1437
1439 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1440
1441 options = 0xf;
1443 ok(SUCCEEDED(hr), "Failed to get traversal options, hr %#lx.\n", hr);
1444 ok(options == 0, "Unexpected traversal options %#lx.\n", options);
1445
1447 ok(SUCCEEDED(hr), "Failed to set traversal options, hr %#lx.\n", hr);
1448
1449 options = 0;
1451 ok(SUCCEEDED(hr), "Failed to get traversal options, hr %#lx.\n", hr);
1452 ok(options == D3DRMFRAME_PICKENABLE, "Unexpected traversal options %#lx.\n", options);
1453
1455
1456 /* Cleanup */
1457 IDirect3DRMFrame_Release(pFrameP2);
1458 CHECK_REFCOUNT(pFrameC, 1);
1459 CHECK_REFCOUNT(pFrameP1, 1);
1460
1461 IDirect3DRMFrame_Release(pFrameC);
1462 IDirect3DRMFrame_Release(pFrameP1);
1463
1465}
#define broken(x)
Definition: atltest.h:178
#define IDirect3DRM_CreateMeshBuilder(p, a)
Definition: d3drm.h:116
#define IDirect3DRM_CreateLightRGB(p, a, b, c, d, e)
Definition: d3drm.h:122
@ D3DRMLIGHT_SPOT
Definition: d3drmdef.h:61
#define D3DRMFRAME_PICKENABLE
Definition: d3drmdef.h:320
#define D3DRMFRAME_RENDERENABLE
Definition: d3drmdef.h:319
#define IDirect3DRMFrame_AddLight(p, a)
Definition: d3drmobj.h:1180
#define IDirect3DRMLight_Release(p)
Definition: d3drmobj.h:3120
#define IDirect3DRMLightArray_GetElement(p, a, b)
Definition: d3drmobj.h:4462
#define IDirect3DRMLightArray_Release(p)
Definition: d3drmobj.h:4458
#define IDirect3DRMFrame_DeleteVisual(p, a)
Definition: d3drmobj.h:1209
#define IDirect3DRMFrame3_GetTraversalOptions(p, a)
Definition: d3drmobj.h:1792
#define IDirect3DRMFrame_GetParent(p, a)
Definition: d3drmobj.h:1191
#define IDirect3DRMFrame_AddChild(p, a)
Definition: d3drmobj.h:1179
#define IDirect3DRMFrame_GetSceneBackground(p)
Definition: d3drmobj.h:1210
#define IDirect3DRMFrameArray_GetSize(p)
Definition: d3drmobj.h:4274
#define IDirect3DRMFrame3_SetTraversalOptions(p, a)
Definition: d3drmobj.h:1791
#define IDirect3DRMFrameArray_GetElement(p, a, b)
Definition: d3drmobj.h:4276
#define IDirect3DRMFrame_GetChildren(p, a)
Definition: d3drmobj.h:1187
#define IDirect3DRMFrame_GetLights(p, a)
Definition: d3drmobj.h:1189
#define IDirect3DRMFrame_SetSceneBackground(p, a)
Definition: d3drmobj.h:1216
#define IDirect3DRMFrame_GetScene(p, a)
Definition: d3drmobj.h:1194
#define IDirect3DRMFrame_DeleteLight(p, a)
Definition: d3drmobj.h:1207
#define IDirect3DRMFrame_DeleteChild(p, a)
Definition: d3drmobj.h:1206
#define IDirect3DRMFrameArray_Release(p)
Definition: d3drmobj.h:4272
#define IDirect3DRMFrame_AddVisual(p, a)
Definition: d3drmobj.h:1186
#define IDirect3DRMLightArray_GetSize(p)
Definition: d3drmobj.h:4460
#define IDirect3DRMFrame_SetSceneBackgroundRGB(p, a, b, c)
Definition: d3drmobj.h:1217
#define IDirect3DRMMeshBuilder_Release(p)
Definition: d3drmobj.h:2552
Definition: send.c:48

Referenced by START_TEST().

◆ test_frame_mesh_materials()

static void test_frame_mesh_materials ( void  )
static

Definition at line 3542 of file d3drm.c.

3543{
3544 HRESULT hr;
3545 IDirect3DRM *d3drm;
3547 const GUID *req_refiids[] = { &IID_IDirect3DRMFrame };
3548 IDirect3DRMMesh *mesh;
3549 ULONG size;
3550 IDirect3DRMMaterial *material;
3551 IDirect3DRMTexture *texture;
3552 unsigned int i;
3553
3555 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3556
3559 hr = IDirect3DRM_Load(d3drm, &info, NULL, (GUID**)req_refiids, 1, D3DRMLOAD_FROMMEMORY, object_load_callback_frame, (void*)0xdeadbeef, NULL, NULL, NULL);
3560 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3561
3563 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3564
3566 ok(size == 3, "Unexpected count %lu.\n", size);
3567
3568 for (i = 0; i < size; i++)
3569 {
3574
3575 winetest_push_context("Group %u", i);
3576
3578 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3579 ok(vertex_count == groups[i].vertex_count, "Wrong vertex count %d, expected %d\n", vertex_count, groups[i].vertex_count);
3580 ok(face_count == groups[i].face_count, "Wrong face count %d; expected %d\n", face_count, groups[i].face_count);
3581 ok(vertex_per_face == groups[i].vertex_per_face, "Wrong vertex per face %d, expected %d\n", vertex_per_face, groups[i].vertex_per_face);
3582 ok(face_data_size == groups[i].face_data_size, "Wrong face data size %ld, expected %d\n", face_data_size, groups[i].face_data_size);
3583
3585 ok(color == groups[i].color, "Wrong color %lx, expected %lx.\n", color, groups[i].color);
3586
3588 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3589 ok(material != NULL, "No material.\n");
3591 ok(power == groups[i].power, "Wrong power %f, expected %f\n", power, groups[i].power);
3593 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3594 ok(red == groups[i].specular[0], "Wrong specular red %f, expected %f\n", red, groups[i].specular[0]);
3595 ok(green == groups[i].specular[1], "Wrong specular green %f, pD3DRMexpected %f\n", green, groups[i].specular[1]);
3596 ok(blue == groups[i].specular[2], "Wrong specular blue %f, expected %f\n", blue, groups[i].specular[2]);
3598 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3599 ok(red == groups[i].emissive[0], "Wrong emissive red %f, expected %f\n", red, groups[i].emissive[0]);
3600 ok(green == groups[i].emissive[1], "Wrong emissive green %f, expected %f\n", green, groups[i].emissive[1]);
3601 ok(blue == groups[i].emissive[2], "Wrong emissive blue %f, expected %f\n", blue, groups[i].emissive[2]);
3602
3604 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
3605 ok(!texture, "Unexpected texture\n");
3606
3607 if (material)
3609 if (texture)
3611
3613 }
3614
3618}
#define IDirect3DRMMesh_GetGroupCount(p)
Definition: d3drmobj.h:1963
#define IDirect3DRMMaterial_GetSpecular(p, a, b, c)
Definition: d3drmobj.h:3672
#define IDirect3DRMMaterial_Release(p)
Definition: d3drmobj.h:3657
#define IDirect3DRMMaterial_GetPower(p)
Definition: d3drmobj.h:3671
#define IDirect3DRMMesh_GetGroup(p, a, b, c, d, e, f)
Definition: d3drmobj.h:1964
#define IDirect3DRMMesh_GetGroupColor(p, a)
Definition: d3drmobj.h:1966
#define IDirect3DRMMeshBuilder_CreateMesh(p, a)
Definition: d3drmobj.h:2600
#define IDirect3DRMMesh_GetGroupMaterial(p, a, b)
Definition: d3drmobj.h:1969
#define IDirect3DRMMaterial_GetEmissive(p, a, b, c)
Definition: d3drmobj.h:3673
#define IDirect3DRMMesh_Release(p)
Definition: d3drmobj.h:1941
#define IDirect3DRMMesh_GetGroupTexture(p, a, b)
Definition: d3drmobj.h:1970
float D3DVALUE
Definition: d3dtypes.h:89
GLclampf green
Definition: gl.h:1740
GLclampf GLclampf blue
Definition: gl.h:1740
GLenum GLuint texture
Definition: glext.h:6295
GLsizei GLuint * groups
Definition: glext.h:11113
#define red
Definition: linetest.c:67
float specular[3]
Definition: d3drm.c:3534
int face_count
Definition: d3drm.c:3529
static char data_frame_mesh_materials[]
Definition: d3drm.c:392
int vertex_per_face
Definition: d3drm.c:3530
static void __cdecl object_load_callback_frame(IDirect3DRMObject *object, REFIID object_guid, void *arg)
Definition: d3drm.c:3493
int face_data_size
Definition: d3drm.c:3531
float emissive[3]
Definition: d3drm.c:3535
float power
Definition: d3drm.c:3533
Definition: mesh.c:189

Referenced by START_TEST().

◆ test_frame_qi()

static void test_frame_qi ( void  )
static

Definition at line 3761 of file d3drm.c.

3762{
3763 static const struct qi_test tests[] =
3764 {
3765 { &IID_IDirect3DRMFrame3, &IID_IUnknown, &IID_IDirect3DRMFrame3, S_OK },
3766 { &IID_IDirect3DRMFrame2, &IID_IUnknown, &IID_IDirect3DRMFrame2, S_OK },
3767 { &IID_IDirect3DRMFrame, &IID_IUnknown, &IID_IDirect3DRMFrame, S_OK },
3768 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3769 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3770 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMFrame, S_OK },
3771 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3772 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3773 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3774 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3775 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3776 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3777 { &IID_IDirect3DRMVisual, &IID_IUnknown, &IID_IDirect3DRMFrame, S_OK },
3778 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3779 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3780 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3781 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3782 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3783 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3784 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3785 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3786 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3787 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3788 { &IID_IDirect3DRMWrap, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3789 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3790 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3791 { &IID_IDirect3DRMAnimation, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3792 { &IID_IDirect3DRMAnimation2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3793 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3794 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3795 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3796 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3797 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3798 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3799 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3800 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3801 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3802 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3803 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3804 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3805 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3806 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3807 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3808 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3809 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3810 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3811 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3812 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3813 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3814 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3815 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3816 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3817 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3818 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3819 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3820 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3821 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3822 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3823 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3824 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3825 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3826 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3827 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3828 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3829 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3830 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
3832 };
3833 HRESULT hr;
3834 IDirect3DRM *d3drm1;
3835 IDirect3DRM2 *d3drm2;
3836 IDirect3DRM3 *d3drm3;
3837 IDirect3DRMFrame *frame1;
3838 IDirect3DRMFrame2 *frame2;
3839 IDirect3DRMFrame3 *frame3;
3841
3842 hr = Direct3DRMCreate(&d3drm1);
3843 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
3844
3845 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame1);
3846 ok(hr == D3DRM_OK, "Failed to create frame1, hr %#lx\n", hr);
3848 ok(hr == D3DRM_OK, "Failed to create IUnknown from frame1, hr %#lx\n", hr);
3850 test_qi("frame1_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
3851 IUnknown_Release(unknown);
3852
3853 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
3854 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
3855 hr = IDirect3DRM2_CreateFrame(d3drm2, NULL, &frame2);
3856 ok(hr == D3DRM_OK, "Failed to create frame2, hr %#lx\n", hr);
3858 ok(hr == D3DRM_OK, "Failed to create IUnknown from frame2, hr %#lx\n", hr);
3860 test_qi("frame2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
3861 IUnknown_Release(unknown);
3862
3863 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
3864 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
3865 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
3866 ok(hr == D3DRM_OK, "Failed to create frame3, hr %#lx\n", hr);
3868 ok(hr == D3DRM_OK, "Failed to create IUnknown from frame3, hr %#lx\n", hr);
3870 test_qi("frame3_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
3871 IUnknown_Release(unknown);
3872
3873 IDirect3DRM3_Release(d3drm3);
3874 IDirect3DRM2_Release(d3drm2);
3875 IDirect3DRM_Release(d3drm1);
3876}
#define IDirect3DRM2_CreateFrame(p, a, b)
Definition: d3drm.h:255
#define IDirect3DRM3_CreateFrame(p, a, b)
Definition: d3drm.h:403
#define IDirect3DRMFrame3_QueryInterface(p, a, b)
Definition: d3drmobj.h:1706
#define IDirect3DRMFrame2_Release(p)
Definition: d3drmobj.h:1418
#define IDirect3DRMFrame2_QueryInterface(p, a, b)
Definition: d3drmobj.h:1416

Referenced by START_TEST().

◆ test_frame_transform()

static void test_frame_transform ( void  )
static

Definition at line 3192 of file d3drm.c.

3193{
3194 IDirect3DRMFrame *frame, *subframe;
3195 D3DRMMATRIX4D matrix, add_matrix;
3196 IDirect3DRM *d3drm;
3197 D3DVECTOR v1, v2;
3198 HRESULT hr;
3199
3201 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3202
3204 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3205
3207 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3209 1.0f, 0.0f, 0.0f, 0.0f,
3210 0.0f, 1.0f, 0.0f, 0.0f,
3211 0.0f, 0.0f, 1.0f, 0.0f,
3212 0.0f, 0.0f, 0.0f, 1.0f, 0);
3213
3214 memcpy(add_matrix, identity, sizeof(add_matrix));
3215 add_matrix[3][0] = 3.0f;
3216 add_matrix[3][1] = 3.0f;
3217 add_matrix[3][2] = 3.0f;
3218
3219 frame_set_transform(frame,
3220 2.0f, 0.0f, 0.0f, 0.0f,
3221 0.0f, 2.0f, 0.0f, 0.0f,
3222 0.0f, 0.0f, 2.0f, 0.0f,
3223 0.0f, 0.0f, 0.0f, 1.0f);
3225 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3227 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3229 1.0f, 0.0f, 0.0f, 0.0f,
3230 0.0f, 1.0f, 0.0f, 0.0f,
3231 0.0f, 0.0f, 1.0f, 0.0f,
3232 3.0f, 3.0f, 3.0f, 1.0f, 1);
3233
3234 frame_set_transform(frame,
3235 2.0f, 0.0f, 0.0f, 0.0f,
3236 0.0f, 2.0f, 0.0f, 0.0f,
3237 0.0f, 0.0f, 2.0f, 0.0f,
3238 0.0f, 0.0f, 0.0f, 1.0f);
3240 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3242 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3244 2.0f, 0.0f, 0.0f, 0.0f,
3245 0.0f, 2.0f, 0.0f, 0.0f,
3246 0.0f, 0.0f, 2.0f, 0.0f,
3247 6.0f, 6.0f, 6.0f, 1.0f, 1);
3248
3249 frame_set_transform(frame,
3250 2.0f, 0.0f, 0.0f, 0.0f,
3251 0.0f, 2.0f, 0.0f, 0.0f,
3252 0.0f, 0.0f, 2.0f, 0.0f,
3253 0.0f, 0.0f, 0.0f, 1.0f);
3255 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3257 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3259 2.0f, 0.0f, 0.0f, 0.0f,
3260 0.0f, 2.0f, 0.0f, 0.0f,
3261 0.0f, 0.0f, 2.0f, 0.0f,
3262 3.0f, 3.0f, 3.0f, 1.0f, 1);
3263
3264 add_matrix[3][3] = 2.0f;
3266 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
3267
3268 frame_set_transform(frame,
3269 2.0f, 0.0f, 0.0f, 0.0f,
3270 0.0f, 2.0f, 0.0f, 0.0f,
3271 0.0f, 0.0f, 2.0f, 0.0f,
3272 0.0f, 0.0f, 0.0f, 1.0f);
3273 hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_REPLACE, 3.0f, 3.0f, 3.0f);
3274 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3276 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3278 1.0f, 0.0f, 0.0f, 0.0f,
3279 0.0f, 1.0f, 0.0f, 0.0f,
3280 0.0f, 0.0f, 1.0f, 0.0f,
3281 3.0f, 3.0f, 3.0f, 1.0f, 1);
3282
3283 frame_set_transform(frame,
3284 2.0f, 0.0f, 0.0f, 0.0f,
3285 0.0f, 2.0f, 0.0f, 0.0f,
3286 0.0f, 0.0f, 2.0f, 0.0f,
3287 0.0f, 0.0f, 0.0f, 1.0f);
3288 hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_BEFORE, 3.0f, 3.0f, 3.0f);
3289 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3291 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3293 2.0f, 0.0f, 0.0f, 0.0f,
3294 0.0f, 2.0f, 0.0f, 0.0f,
3295 0.0f, 0.0f, 2.0f, 0.0f,
3296 6.0f, 6.0f, 6.0f, 1.0f, 1);
3297
3298 frame_set_transform(frame,
3299 2.0f, 0.0f, 0.0f, 0.0f,
3300 0.0f, 2.0f, 0.0f, 0.0f,
3301 0.0f, 0.0f, 2.0f, 0.0f,
3302 0.0f, 0.0f, 0.0f, 1.0f);
3303 hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_AFTER, 3.0f, 3.0f, 3.0f);
3304 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3306 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3308 2.0f, 0.0f, 0.0f, 0.0f,
3309 0.0f, 2.0f, 0.0f, 0.0f,
3310 0.0f, 0.0f, 2.0f, 0.0f,
3311 3.0f, 3.0f, 3.0f, 1.0f, 1);
3312
3313 frame_set_transform(frame,
3314 1.0f, 0.0f, 0.0f, 0.0f,
3315 0.0f, 1.0f, 0.0f, 0.0f,
3316 0.0f, 0.0f, 1.0f, 0.0f,
3317 3.0f, 3.0f, 3.0f, 1.0f);
3318 hr = IDirect3DRMFrame_AddScale(frame, D3DRMCOMBINE_REPLACE, 2.0f, 2.0f, 2.0f);
3319 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3321 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3323 2.0f, 0.0f, 0.0f, 0.0f,
3324 0.0f, 2.0f, 0.0f, 0.0f,
3325 0.0f, 0.0f, 2.0f, 0.0f,
3326 0.0f, 0.0f, 0.0f, 1.0f, 1);
3327
3328 frame_set_transform(frame,
3329 1.0f, 0.0f, 0.0f, 0.0f,
3330 0.0f, 1.0f, 0.0f, 0.0f,
3331 0.0f, 0.0f, 1.0f, 0.0f,
3332 3.0f, 3.0f, 3.0f, 1.0f);
3333 hr = IDirect3DRMFrame_AddScale(frame, D3DRMCOMBINE_BEFORE, 2.0f, 2.0f, 2.0f);
3334 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3336 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3338 2.0f, 0.0f, 0.0f, 0.0f,
3339 0.0f, 2.0f, 0.0f, 0.0f,
3340 0.0f, 0.0f, 2.0f, 0.0f,
3341 3.0f, 3.0f, 3.0f, 1.0f, 1);
3342
3343 frame_set_transform(frame,
3344 1.0f, 0.0f, 0.0f, 0.0f,
3345 0.0f, 1.0f, 0.0f, 0.0f,
3346 0.0f, 0.0f, 1.0f, 0.0f,
3347 3.0f, 3.0f, 3.0f, 1.0f);
3348 hr = IDirect3DRMFrame_AddScale(frame, D3DRMCOMBINE_AFTER, 2.0f, 2.0f, 2.0f);
3349 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3351 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3353 2.0f, 0.0f, 0.0f, 0.0f,
3354 0.0f, 2.0f, 0.0f, 0.0f,
3355 0.0f, 0.0f, 2.0f, 0.0f,
3356 6.0f, 6.0f, 6.0f, 1.0f, 1);
3357
3358 frame_set_transform(frame,
3359 1.0f, 0.0f, 0.0f, 0.0f,
3360 0.0f, 1.0f, 0.0f, 0.0f,
3361 0.0f, 0.0f, 1.0f, 0.0f,
3362 3.0f, 3.0f, 3.0f, 1.0f);
3363 hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_REPLACE, 1.0f, 0.0f, 0.0f, M_PI_2);
3364 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3368 1.0f, 0.0f, 0.0f, 0.0f,
3369 0.0f, 0.0f, 1.0f, 0.0f,
3370 0.0f, -1.0f, 0.0f, 0.0f,
3371 0.0f, 0.0f, 0.0f, 1.0f, 1);
3372
3373 frame_set_transform(frame,
3374 1.0f, 0.0f, 0.0f, 0.0f,
3375 0.0f, 1.0f, 0.0f, 0.0f,
3376 0.0f, 0.0f, 1.0f, 0.0f,
3377 3.0f, 3.0f, 3.0f, 1.0f);
3378 hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_BEFORE, 1.0f, 0.0f, 0.0f, M_PI_2);
3379 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3381 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3384 1.0f, 0.0f, 0.0f, 0.0f,
3385 0.0f, 0.0f, 1.0f, 0.0f,
3386 0.0f, -1.0f, 0.0f, 0.0f,
3387 3.0f, 3.0f, 3.0f, 1.0f, 1);
3388
3389 frame_set_transform(frame,
3390 1.0f, 0.0f, 0.0f, 0.0f,
3391 0.0f, 1.0f, 0.0f, 0.0f,
3392 0.0f, 0.0f, 1.0f, 0.0f,
3393 3.0f, 3.0f, 3.0f, 1.0f);
3394 hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_AFTER, 1.0f, 0.0f, 0.0f, M_PI_2);
3395 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3397 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3400 1.0f, 0.0f, 0.0f, 0.0f,
3401 0.0f, 0.0f, 1.0f, 0.0f,
3402 0.0f, -1.0f, 0.0f, 0.0f,
3403 3.0f, -3.0f, 3.0f, 1.0f, 1);
3404
3405 hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_REPLACE, 0.0f, 0.0f, 1.0f, M_PI_2);
3406 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3408 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3411 0.0f, 1.0f, 0.0f, 0.0f,
3412 -1.0f, 0.0f, 0.0f, 0.0f,
3413 0.0f, 0.0f, 1.0f, 0.0f,
3414 0.0f, 0.0f, 0.0f, 1.0f, 1);
3415
3416 hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_REPLACE, 0.0f, 0.0f, 0.0f, M_PI_2);
3417 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3419 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3422 1.0f, 0.0f, 0.0f, 0.0f,
3423 0.0f, 0.0f, 1.0f, 0.0f,
3424 0.0f, -1.0f, 0.0f, 0.0f,
3425 0.0f, 0.0f, 0.0f, 1.0f, 1);
3426
3427 frame_set_transform(frame,
3428 2.0f, 0.0f, 0.0f, 0.0f,
3429 0.0f, 4.0f, 0.0f, 0.0f,
3430 0.0f, 0.0f, 8.0f, 0.0f,
3431 64.0f, 64.0f, 64.0f, 1.0f);
3432 hr = IDirect3DRM_CreateFrame(d3drm, frame, &subframe);
3433 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3434 frame_set_transform(subframe,
3435 1.0f, 0.0f, 0.0f, 0.0f,
3436 0.0f, 1.0f, 0.0f, 0.0f,
3437 0.0f, 0.0f, 1.0f, 0.0f,
3438 11.0f, 11.0f, 11.0f, 1.0f);
3439 set_vector(&v1, 3.0f, 5.0f, 7.0f);
3440
3441 hr = IDirect3DRMFrame_Transform(frame, &v2, &v1);
3442 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3443 expect_vector(&v2, 70.0f, 84.0f, 120.0f, 1);
3444
3445 hr = IDirect3DRMFrame_Transform(subframe, &v2, &v1);
3446 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
3447 expect_vector(&v2, 92.0f, 128.0f, 208.0f, 1);
3448
3449 IDirect3DRMFrame_Release(subframe);
3452}
@ D3DRMCOMBINE_BEFORE
Definition: d3drmdef.h:126
@ D3DRMCOMBINE_AFTER
Definition: d3drmdef.h:127
#define IDirect3DRMFrame_AddRotation(p, a, b, c, d, e)
Definition: d3drmobj.h:1185
#define IDirect3DRMFrame_GetTransform(p, a)
Definition: d3drmobj.h:1197
#define IDirect3DRMFrame_AddTranslation(p, a, b, c, d)
Definition: d3drmobj.h:1183
#define IDirect3DRMFrame_Transform(p, a, b)
Definition: d3drmobj.h:1236
#define IDirect3DRMFrame_AddScale(p, a, b, c, d)
Definition: d3drmobj.h:1184
#define M_PI_2
Definition: math.h:410
#define expect_matrix(m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u)
Definition: d3drm.c:67
static void set_vector(D3DVECTOR *v, float x, float y, float z)
Definition: d3drm.c:140
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)
Definition: d3drm.c:125
#define expect_vector(v, x, y, z, u)
Definition: d3drm.c:93
static void matrix_sanitise(D3DRMMATRIX4D m)
Definition: d3drm.c:147

Referenced by START_TEST().

◆ test_Light()

static void test_Light ( void  )
static

Definition at line 2568 of file d3drm.c.

2569{
2570 IDirect3DRMObject *object;
2571 HRESULT hr;
2572 IDirect3DRM *d3drm;
2573 IDirect3DRMLight *light;
2576
2578 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
2579
2581 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface, hr %#lx\n", hr);
2582
2583 hr = IDirect3DRMLight_QueryInterface(light, &IID_IDirect3DRMObject, (void **)&object);
2584 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr %#lx.\n", hr);
2586
2587 test_class_name((IDirect3DRMObject *)light, "Light");
2588 test_object_name((IDirect3DRMObject *)light);
2589
2591 ok(type == D3DRMLIGHT_SPOT, "wrong type (%u)\n", type);
2592
2594 ok(color == 0xff7f7f7f, "wrong color %lx.\n", color);
2595
2597 ok(hr == D3DRM_OK, "Cannot set type, hr %#lx\n", hr);
2599 ok(type == D3DRMLIGHT_POINT, "wrong type %u.\n", type);
2600
2601 hr = IDirect3DRMLight_SetColor(light, 0xff180587);
2602 ok(hr == D3DRM_OK, "Cannot set color, hr %#lx\n", hr);
2604 ok(color == 0xff180587, "wrong color %#lx.\n", color);
2605
2606 hr = IDirect3DRMLight_SetColor(light, 0x00c0c0c0);
2607 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2609 ok(color == 0xffc0c0c0, "Got unexpected color 0x%08lx.\n", color);
2610
2611 hr = IDirect3DRMLight_SetColorRGB(light, 0.5, 0.5, 0.5);
2612 ok(hr == D3DRM_OK, "Cannot set color, hr %#lx\n", hr);
2614 ok(color == 0xff7f7f7f, "wrong color %#lx.\n", color);
2615
2617
2619 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2620
2622 ok(type == D3DRMLIGHT_SPOT, "Got unexpected type %#x.\n", type);
2623
2625 ok(color == 0xffc0c0c0, "Got unexpected color 0x%08lx.\n", color);
2626
2628
2630}
#define IDirect3DRM_CreateLight(p, a, b, c)
Definition: d3drm.h:121
@ D3DRMLIGHT_POINT
Definition: d3drmdef.h:60
enum _D3DRMLIGHTTYPE D3DRMLIGHTTYPE
#define IDirect3DRMLight_GetType(p)
Definition: d3drmobj.h:3147
#define IDirect3DRMLight_QueryInterface(p, a, b)
Definition: d3drmobj.h:3118
#define IDirect3DRMLight_SetColorRGB(p, a, b, c)
Definition: d3drmobj.h:3133
#define IDirect3DRMLight_GetColor(p)
Definition: d3drmobj.h:3146
#define IDirect3DRMLight_SetType(p, a)
Definition: d3drmobj.h:3131
#define IDirect3DRMLight_SetColor(p, a)
Definition: d3drmobj.h:3132
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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 light
Definition: glfuncs.h:170

Referenced by START_TEST().

◆ test_load_texture()

static void test_load_texture ( void  )
static

Definition at line 6357 of file d3drm.c.

6358{
6359 IDirect3DRMTexture3 *texture3;
6360 IDirect3DRMTexture2 *texture2;
6361 IDirect3DRMTexture *texture1;
6362 D3DRMIMAGE *d3drm_img;
6363 IDirect3DRM3 *d3drm3;
6364 IDirect3DRM2 *d3drm2;
6365 IDirect3DRM *d3drm1;
6366 ULONG ref1, ref2;
6367 unsigned int i;
6368 char *filename;
6369 HRESULT hr;
6370 BOOL ret;
6371
6372 static const struct
6373 {
6374 unsigned int w;
6375 unsigned int h;
6376 BOOL palettized;
6377 }
6378 tests[] =
6379 {
6380 {100, 100, TRUE },
6381 {99, 100, TRUE },
6382 {100, 100, FALSE},
6383 {99, 100, FALSE},
6384 {3, 39, FALSE},
6385 {16, 16, FALSE},
6386 };
6387
6388 hr = Direct3DRMCreate(&d3drm1);
6389 ok(hr == D3DRM_OK, "Failed to create IDirect3DRM object, hr %#lx.\n", hr);
6390 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
6391 ok(SUCCEEDED(hr), "Failed to get IDirect3DRM2 interface, hr %#lx.\n", hr);
6392 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
6393 ok(SUCCEEDED(hr), "Failed to get IDirect3DRM3 interface, hr %#lx.\n", hr);
6394 ref1 = get_refcount((IUnknown *)d3drm1);
6395
6396 /* Test all failures together. */
6397 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
6398 hr = IDirect3DRM_LoadTexture(d3drm1, NULL, &texture1);
6399 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
6400 ok(!texture1, "Got unexpected texture %p.\n", texture1);
6401 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
6402 hr = IDirect3DRM_LoadTexture(d3drm1, "", &texture1);
6403 ok(hr == D3DRMERR_FILENOTFOUND, "Got unexpected hr %#lx.\n", hr);
6404 ok(!texture1, "Got unexpected texture %p.\n", texture1);
6405 hr = IDirect3DRM_LoadTexture(d3drm1, NULL, NULL);
6406 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
6407
6408 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
6409 hr = IDirect3DRM2_LoadTexture(d3drm2, NULL, &texture2);
6410 ok(hr == D3DRMERR_FILENOTFOUND, "Got unexpected hr %#lx.\n", hr);
6411 ok(!texture2, "Got unexpected texture %p.\n", texture2);
6412 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
6413 hr = IDirect3DRM2_LoadTexture(d3drm2, "", &texture2);
6414 ok(hr == D3DRMERR_FILENOTFOUND, "Got unexpected hr %#lx.\n", hr);
6415 ok(!texture2, "Got unexpected texture %p.\n", texture2);
6417 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
6418
6419 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
6420 hr = IDirect3DRM3_LoadTexture(d3drm3, NULL, &texture3);
6421 ok(hr == D3DRMERR_FILENOTFOUND, "Got unexpected hr %#lx.\n", hr);
6422 ok(!texture3, "Got unexpected texture %p.\n", texture3);
6423 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
6424 hr = IDirect3DRM_LoadTexture(d3drm3, "", &texture3);
6425 ok(hr == D3DRMERR_FILENOTFOUND, "Got unexpected hr %#lx.\n", hr);
6426 ok(!texture3, "Got unexpected texture %p.\n", texture3);
6428 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
6429
6430 for (i = 0; i < ARRAY_SIZE(tests); ++i)
6431 {
6432 winetest_push_context("Test %u", i);
6433
6434 filename = create_bitmap(tests[i].w, tests[i].h, tests[i].palettized);
6435
6436 hr = IDirect3DRM_LoadTexture(d3drm1, filename, &texture1);
6437 ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
6438 ref2 = get_refcount((IUnknown *)d3drm1);
6439 ok(ref2 > ref1, "Expected ref2 > ref1, got ref1 %lu, ref2 %lu.\n", ref1, ref2);
6440
6442 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6443 /* InitFromFile() seems to AddRef() IDirect3DRM even if it fails. */
6444 IDirect3DRM_Release(d3drm1);
6445 d3drm_img = IDirect3DRMTexture_GetImage(texture1);
6446 ok(!!d3drm_img, "Failed to get image.\n");
6447 test_bitmap_data(i * 7, d3drm_img, FALSE, tests[i].w, tests[i].h, tests[i].palettized);
6449 ref2 = get_refcount((IUnknown *)d3drm1);
6450 ok(ref1 == ref2, "Expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
6451 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMTexture,
6452 NULL, &IID_IDirect3DRMTexture, (void **)&texture1);
6453 ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
6455 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6456 hr = IDirect3DRMTexture_InitFromFile(texture1, "");
6457 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6459 ok(SUCCEEDED(hr), "Failed to initialise texture from file, hr %#lx.\n", hr);
6460 d3drm_img = IDirect3DRMTexture_GetImage(texture1);
6461 ok(!!d3drm_img, "Failed to get image.\n");
6462 test_bitmap_data(i * 7 + 1, d3drm_img, FALSE, tests[i].w, tests[i].h, tests[i].palettized);
6464
6465 hr = IDirect3DRM2_LoadTexture(d3drm2, filename, &texture2);
6466 ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
6467 ref2 = get_refcount((IUnknown *)d3drm1);
6468 ok(ref2 > ref1, "Expected ref2 > ref1, got ref1 %lu, ref2 %lu.\n", ref1, ref2);
6469
6471 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6472 IDirect3DRM_Release(d3drm1);
6473 d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
6474 ok(!!d3drm_img, "Failed to get image.\n");
6475 test_bitmap_data(i * 7 + 2, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized);
6477 ref2 = get_refcount((IUnknown *)d3drm1);
6478 ok(ref1 == ref2, "Expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
6479 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture,
6480 NULL, &IID_IDirect3DRMTexture2, (void **)&texture2);
6481 ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
6483 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6484 hr = IDirect3DRMTexture2_InitFromFile(texture2, "");
6485 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6487 ok(SUCCEEDED(hr), "Failed to initialise texture from file, hr %#lx.\n", hr);
6488 d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
6489 ok(!!d3drm_img, "Failed to get image.\n");
6490 test_bitmap_data(i * 7 + 3, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized);
6492
6493 hr = IDirect3DRM3_LoadTexture(d3drm3, filename, &texture3);
6494 ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
6495 ref2 = get_refcount((IUnknown *)d3drm1);
6496 ok(ref2 > ref1, "Expected ref2 > ref1, got ref1 %lu, ref2 %lu.\n", ref1, ref2);
6497
6499 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6500 IDirect3DRM_Release(d3drm1);
6501 d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
6502 ok(!!d3drm_img, "Failed to get image.\n");
6503 test_bitmap_data(i * 7 + 4, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized);
6504 /* Test whether querying a version 1 texture from version 3 causes a
6505 * change in the loading behavior. */
6506 hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture, (void **)&texture1);
6507 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMTexture interface, hr %#lx.\n", hr);
6508 d3drm_img = IDirect3DRMTexture_GetImage(texture1);
6509 ok(!!d3drm_img, "Failed to get image.\n");
6510 test_bitmap_data(i * 7 + 5, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized);
6513 ref2 = get_refcount((IUnknown *)d3drm1);
6514 ok(ref1 == ref2, "Expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
6515
6516 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture,
6517 NULL, &IID_IDirect3DRMTexture3, (void **)&texture3);
6518 ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
6520 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6521 hr = IDirect3DRMTexture3_InitFromFile(texture3, "");
6522 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
6524 ok(SUCCEEDED(hr), "Failed to initialize texture from file, hr %#lx.\n", hr);
6525 d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
6526 ok(!!d3drm_img, "Failed to get image.\n");
6527 test_bitmap_data(i * 7 + 6, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized);
6529
6531 ok(ret, "Failed to delete bitmap \"%s\".\n", filename);
6532 free(filename);
6533
6535 }
6536
6537 IDirect3DRM3_Release(d3drm3);
6538 IDirect3DRM2_Release(d3drm2);
6539 IDirect3DRM_Release(d3drm1);
6540}
#define IDirect3DRM3_LoadTexture(p, a, b)
Definition: d3drm.h:422
#define D3DRMERR_FILENOTFOUND
Definition: d3drm.h:493
#define IDirect3DRM_LoadTexture(p, a, b)
Definition: d3drm.h:133
#define IDirect3DRM2_LoadTexture(p, a, b)
Definition: d3drm.h:274
#define IDirect3DRMTexture3_InitFromFile(p, a)
Definition: d3drmobj.h:3487
#define IDirect3DRMTexture_InitFromFile(p, a)
Definition: d3drmobj.h:3243
#define IDirect3DRMTexture2_Release(p)
Definition: d3drmobj.h:3348
#define IDirect3DRMTexture3_QueryInterface(p, a, b)
Definition: d3drmobj.h:3474
#define IDirect3DRMTexture2_InitFromFile(p, a)
Definition: d3drmobj.h:3359
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static void test_bitmap_data(unsigned int test_idx, const D3DRMIMAGE *img, BOOL upside_down, unsigned int w, unsigned int h, BOOL palettized)
Definition: d3drm.c:6240
static HBITMAP create_bitmap(void)
Definition: clipboard.c:588

Referenced by START_TEST().

◆ test_Material2()

static void test_Material2 ( void  )
static

Definition at line 2632 of file d3drm.c.

2633{
2634 HRESULT hr;
2635 IDirect3DRM *d3drm;
2636 IDirect3DRM3 *d3drm3;
2637 IDirect3DRMMaterial2 *material2;
2638 D3DVALUE r, g, b;
2639
2641 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
2642
2643 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
2644 {
2645 win_skip("Cannot get IDirect3DRM3 interface, hr %#lx, skipping tests\n", hr);
2647 return;
2648 }
2649
2650 hr = IDirect3DRM3_CreateMaterial(d3drm3, 18.5f, &material2);
2651 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMaterial2 interface, hr %#lx\n", hr);
2652
2653 test_class_name((IDirect3DRMObject *)material2, "Material");
2654 test_object_name((IDirect3DRMObject *)material2);
2655
2656 r = IDirect3DRMMaterial2_GetPower(material2);
2657 ok(r == 18.5f, "wrong power (%f)\n", r);
2658
2659 hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b);
2660 ok(hr == D3DRM_OK, "Cannot get emissive, hr %#lx\n", hr);
2661 ok(r == 0.0f && g == 0.0f && b == 0.0f, "wrong emissive r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r, g, b);
2662
2663 hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b);
2664 ok(hr == D3DRM_OK, "Cannot get emissive, hr %#lx\n", hr);
2665 ok(r == 1.0f && g == 1.0f && b == 1.0f, "wrong specular r=%f g=%f b=%f, expected r=1.0 g=1.0 b=1.0\n", r, g, b);
2666
2667 hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b);
2668 ok(hr == D3DRM_OK, "Cannot get emissive, hr %#lx\n", hr);
2669 ok(r == 0.0f && g == 0.0f && b == 0.0f, "wrong ambient r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r, g, b);
2670
2671 hr = IDirect3DRMMaterial2_SetPower(material2, 5.87f);
2672 ok(hr == D3DRM_OK, "Cannot set power, hr %#lx\n", hr);
2673 r = IDirect3DRMMaterial2_GetPower(material2);
2674 ok(r == 5.87f, "wrong power (%f)\n", r);
2675
2676 hr = IDirect3DRMMaterial2_SetEmissive(material2, 0.5f, 0.5f, 0.5f);
2677 ok(hr == D3DRM_OK, "Cannot set emissive, hr %#lx\n", hr);
2678 hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b);
2679 ok(hr == D3DRM_OK, "Cannot get emissive, hr %#lx\n", hr);
2680 ok(r == 0.5f && g == 0.5f && b == 0.5f, "wrong emissive r=%f g=%f b=%f, expected r=0.5 g=0.5 b=0.5\n", r, g, b);
2681
2682 hr = IDirect3DRMMaterial2_SetSpecular(material2, 0.6f, 0.6f, 0.6f);
2683 ok(hr == D3DRM_OK, "Cannot set specular, hr %#lx\n", hr);
2684 hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b);
2685 ok(hr == D3DRM_OK, "Cannot get specular, hr %#lx\n", hr);
2686 ok(r == 0.6f && g == 0.6f && b == 0.6f, "wrong specular r=%f g=%f b=%f, expected r=0.6 g=0.6 b=0.6\n", r, g, b);
2687
2688 hr = IDirect3DRMMaterial2_SetAmbient(material2, 0.7f, 0.7f, 0.7f);
2689 ok(hr == D3DRM_OK, "Cannot set ambient, hr %#lx\n", hr);
2690 hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b);
2691 ok(hr == D3DRM_OK, "Cannot get ambient, hr %#lx\n", hr);
2692 ok(r == 0.7f && g == 0.7f && b == 0.7f, "wrong ambient r=%f g=%f b=%f, expected r=0.7 g=0.7 b=0.7\n", r, g, b);
2693
2695
2696 IDirect3DRM3_Release(d3drm3);
2698}
#define IDirect3DRM3_CreateMaterial(p, a, b)
Definition: d3drm.h:412
#define IDirect3DRMMaterial2_GetEmissive(p, a, b, c)
Definition: d3drmobj.h:3748
#define IDirect3DRMMaterial2_GetSpecular(p, a, b, c)
Definition: d3drmobj.h:3747
#define IDirect3DRMMaterial2_GetAmbient(p, a, b, c)
Definition: d3drmobj.h:3750
#define IDirect3DRMMaterial2_SetPower(p, a)
Definition: d3drmobj.h:3743
#define IDirect3DRMMaterial2_GetPower(p)
Definition: d3drmobj.h:3746
#define IDirect3DRMMaterial2_SetAmbient(p, a, b, c)
Definition: d3drmobj.h:3749
#define IDirect3DRMMaterial2_SetEmissive(p, a, b, c)
Definition: d3drmobj.h:3745
#define IDirect3DRMMaterial2_SetSpecular(p, a, b, c)
Definition: d3drmobj.h:3744
#define IDirect3DRMMaterial2_Release(p)
Definition: d3drmobj.h:3732
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79

Referenced by START_TEST().

◆ test_Mesh()

static void test_Mesh ( void  )
static

Definition at line 817 of file d3drm.c.

818{
819 HRESULT hr;
820 IDirect3DRM *d3drm;
821 IDirect3DRMMesh *mesh;
822 IUnknown *unk;
823
825 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
826
828 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMesh interface, hr %#lx\n", hr);
829
830 test_class_name((IDirect3DRMObject *)mesh, "Mesh");
831 test_object_name((IDirect3DRMObject *)mesh);
832
833 hr = IDirect3DRMMesh_QueryInterface(mesh, &IID_IDirect3DRMObject, (void **)&unk);
834 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
835 IUnknown_Release(unk);
836
837 hr = IDirect3DRMMesh_QueryInterface(mesh, &IID_IDirect3DRMVisual, (void **)&unk);
838 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
839 IUnknown_Release(unk);
840
842
844}
#define IDirect3DRM_CreateMesh(p, a)
Definition: d3drm.h:115
#define IDirect3DRMMesh_QueryInterface(p, a, b)
Definition: d3drmobj.h:1939

Referenced by START_TEST().

◆ test_MeshBuilder()

static void test_MeshBuilder ( void  )
static

Definition at line 434 of file d3drm.c.

435{
436 HRESULT hr;
437 IDirect3DRM *d3drm;
438 IDirect3DRMMeshBuilder *pMeshBuilder;
439 IDirect3DRMMeshBuilder3 *meshbuilder3;
440 IDirect3DRMMesh *mesh;
442 int val;
443 DWORD val1, val2, val3;
444 D3DVALUE valu, valv;
445 D3DVECTOR v[3];
446 D3DVECTOR n[4];
447 DWORD f[8];
448 char name[10];
449 DWORD size;
451 IUnknown *unk;
452
454 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
455
456 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder);
457 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface, hr %#lx\n", hr);
458
459 hr = IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder, &IID_IDirect3DRMObject, (void **)&unk);
460 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
461 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
462 IUnknown_Release(unk);
463
464 hr = IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder, &IID_IDirect3DRMVisual, (void **)&unk);
465 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
466 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
467 IUnknown_Release(unk);
468
469 hr = IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder, &IID_IDirect3DRMMeshBuilder3, (void **)&meshbuilder3);
470 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
471
472 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3, &IID_IDirect3DRMObject, (void **)&unk);
473 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
474 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
475 IUnknown_Release(unk);
476
477 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3, &IID_IDirect3DRMVisual, (void **)&unk);
478 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
479 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
480 IUnknown_Release(unk);
481
483
484 test_class_name((IDirect3DRMObject *)pMeshBuilder, "Builder");
485 test_object_name((IDirect3DRMObject *)pMeshBuilder);
486
487 info.lpMemory = data_bad_version;
490 ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE, hr %#lx\n", hr);
491
492 info.lpMemory = data_no_mesh;
493 info.dSize = strlen(data_no_mesh);
495 ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND, hr %#lx\n", hr);
496
497 info.lpMemory = data_ok;
498 info.dSize = strlen(data_ok);
500 ok(hr == D3DRM_OK, "Cannot load mesh data, hr %#lx\n", hr);
501
502 size = sizeof(name);
503 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
504 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
505 ok(!strcmp(name, "Object"), "Retrieved name '%s' instead of 'Object'\n", name);
506 size = strlen("Object"); /* No space for null character */
507 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
508 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
509 hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, NULL);
510 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
511 size = sizeof(name);
512 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
513 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
514 ok(size == 0, "Size should be 0 instead of %lu.\n", size);
515 hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, "");
516 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
517 size = sizeof(name);
518 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
519 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
520 ok(!strcmp(name, ""), "Retrieved name '%s' instead of ''\n", name);
521
523 ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
524
526 ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
527
528 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, NULL, &val2, NULL, &val3, NULL);
529 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
530 ok(val1 == 4, "Wrong number of vertices %ld (must be 4)\n", val1);
531 ok(val2 == 4, "Wrong number of normals %ld (must be 4)\n", val2);
532 ok(val3 == 22, "Wrong number of face data bytes %ld (must be 22)\n", val3);
533
534 /* Check that Load method generated default normals */
535 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, NULL, &val2, n, NULL, NULL);
536 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
537 expect_vector(&n[0], 0.577350f, 0.577350f, 0.577350f, 32);
538 expect_vector(&n[1], -0.229416f, 0.688247f, 0.688247f, 32);
539 expect_vector(&n[2], -0.229416f, 0.688247f, 0.688247f, 32);
540 expect_vector(&n[3], -0.577350f, 0.577350f, 0.577350f, 32);
541
542 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
543 valu = 1.23f;
544 valv = 3.21f;
545 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv);
546 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
547 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
548 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
549 valu = 1.23f;
550 valv = 3.21f;
551 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 1, &valu, &valv);
552 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
553 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
554 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
555 valu = 1.23f;
556 valv = 3.21f;
557 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 2, &valu, &valv);
558 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
559 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
560 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
561 valu = 1.23f;
562 valv = 3.21f;
563 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 3, &valu, &valv);
564 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
565 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
566 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
567 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 4, &valu, &valv);
568 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr);
569
570 valu = 1.23f;
571 valv = 3.21f;
572 hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 0, valu, valv);
573 ok(hr == D3DRM_OK, "Cannot set texture coordinates, hr %#lx\n", hr);
574 hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 4, valu, valv);
575 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr);
576
577 valu = 0.0f;
578 valv = 0.0f;
579 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv);
580 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
581 ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu);
582 ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv);
583
584 IDirect3DRMMeshBuilder_Release(pMeshBuilder);
585
586 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder);
587 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface, hr %#lx\n", hr);
588
589 /* No group in mesh when mesh builder is not loaded */
590 hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh);
591 ok(hr == D3DRM_OK, "CreateMesh failed returning hr %#lx.\n", hr);
592 if (hr == D3DRM_OK)
593 {
594 DWORD nb_groups;
595
597 ok(nb_groups == 0, "GetCroupCount returned %lu\n", nb_groups);
598
600 }
601
602 info.lpMemory = data_full;
603 info.dSize = strlen(data_full);
605 ok(hr == D3DRM_OK, "Cannot load mesh data, hr %#lx\n", hr);
606
608 ok(val == 3, "Wrong number of vertices %d (must be 3)\n", val);
609
611 ok(val == 1, "Wrong number of faces %d (must be 1)\n", val);
612
613 /* Check no buffer size and too small buffer size errors */
614 val1 = 1; val2 = 3; val3 = 8;
615 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
616 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
617 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, v, &val2, n, &val3, f);
618 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
619 val1 = 3; val2 = 1; val3 = 8;
620 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
621 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
622 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, NULL, n, &val3, f);
623 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
624 val1 = 3; val2 = 3; val3 = 1;
625 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
626 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
627 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, NULL, f);
628 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
629
630 val1 = 3; val2 = 3; val3 = 8;
631 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
632 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
633 ok(val1 == 3, "Wrong number of vertices %ld (must be 3)\n", val1);
634 ok(val2 == 3, "Wrong number of normals %ld (must be 3)\n", val2);
635 ok(val3 == 8, "Wrong number of face data bytes %ld (must be 8)\n", val3);
636 expect_vector(&v[0], 0.1f, 0.2f, 0.3f, 32);
637 expect_vector(&v[1], 0.4f, 0.5f, 0.6f, 32);
638 expect_vector(&v[2], 0.7f, 0.8f, 0.9f, 32);
639 expect_vector(&n[0], 1.1f, 1.2f, 1.3f, 32);
640 expect_vector(&n[1], 1.4f, 1.5f, 1.6f, 32);
641 expect_vector(&n[2], 1.7f, 1.8f, 1.9f, 32);
642 ok(f[0] == 3 , "Wrong component f[0] = %ld (expected 3)\n", f[0]);
643 ok(f[1] == 0 , "Wrong component f[1] = %ld (expected 0)\n", f[1]);
644 ok(f[2] == 0 , "Wrong component f[2] = %ld (expected 0)\n", f[2]);
645 ok(f[3] == 1 , "Wrong component f[3] = %ld (expected 1)\n", f[3]);
646 ok(f[4] == 1 , "Wrong component f[4] = %ld (expected 1)\n", f[4]);
647 ok(f[5] == 2 , "Wrong component f[5] = %ld (expected 2)\n", f[5]);
648 ok(f[6] == 2 , "Wrong component f[6] = %ld (expected 2)\n", f[6]);
649 ok(f[7] == 0 , "Wrong component f[7] = %ld (expected 0)\n", f[7]);
650
651 hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh);
652 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
653 if (hr == D3DRM_OK)
654 {
655 DWORD nb_groups;
656 unsigned nb_vertices, nb_faces, nb_face_vertices;
657 DWORD data_size;
658 IDirect3DRMMaterial *material = (IDirect3DRMMaterial *)0xdeadbeef;
659 IDirect3DRMTexture *texture = (IDirect3DRMTexture *)0xdeadbeef;
660 D3DVALUE values[3];
661
663 ok(nb_groups == 1, "GetCroupCount returned %lu.\n", nb_groups);
664 hr = IDirect3DRMMesh_GetGroup(mesh, 1, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL);
665 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
666 hr = IDirect3DRMMesh_GetGroup(mesh, 0, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL);
667 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
668 ok(nb_vertices == 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices);
669 ok(nb_faces == 1, "Wrong number of faces %u (must be 1)\n", nb_faces);
670 ok(nb_face_vertices == 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices);
671 ok(data_size == 3, "Wrong number of face data bytes %lu (must be 3)\n", data_size);
673 ok(color == 0xff00ff00, "Wrong color returned %#lx instead of %#x\n", color, 0xff00ff00);
675 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
676 ok(texture == NULL, "No texture should be present\n");
678 ok(hr == D3DRM_OK, "Unexpected hr %#lx.\n", hr);
679 ok(material != NULL, "No material present\n");
680 hr = IDirect3DRMMaterial_GetEmissive(material, &values[0], &values[1], &values[2]);
681 ok(hr == D3DRM_OK, "Failed to get emissive color, hr %#lx.\n", hr);
682 ok(values[0] == 0.5f, "Got unexpected red component %.8e.\n", values[0]);
683 ok(values[1] == 0.5f, "Got unexpected green component %.8e.\n", values[1]);
684 ok(values[2] == 0.5f, "Got unexpected blue component %.8e.\n", values[2]);
685 hr = IDirect3DRMMaterial_GetSpecular(material, &values[0], &values[1], &values[2]);
686 ok(hr == D3DRM_OK, "Failed to get specular color, hr %#lx.\n", hr);
687 ok(values[0] == 1.0f, "Got unexpected red component %.8e.\n", values[0]);
688 ok(values[1] == 0.0f, "Got unexpected green component %.8e.\n", values[1]);
689 ok(values[2] == 0.0f, "Got unexpected blue component %.8e.\n", values[2]);
691 ok(values[0] == 30.0f, "Got unexpected power value %.8e.\n", values[0]);
693
695 }
696
697 hr = IDirect3DRMMeshBuilder_Scale(pMeshBuilder, 2, 3 ,4);
698 ok(hr == D3DRM_OK, "Scale failed returning hr %#lx.\n", hr);
699
700 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
701 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
702 ok(val2 == 3, "Wrong number of normals %ld (must be 3)\n", val2);
703 ok(val1 == 3, "Wrong number of vertices %ld (must be 3)\n", val1);
704
705 expect_vector(&v[0], 0.1f * 2, 0.2f * 3, 0.3f * 4, 32);
706 expect_vector(&v[1], 0.4f * 2, 0.5f * 3, 0.6f * 4, 32);
707 expect_vector(&v[2], 0.7f * 2, 0.8f * 3, 0.9f * 4, 32);
708 /* Normals are not affected by Scale */
709 expect_vector(&n[0], 1.1f, 1.2f, 1.3f, 32);
710 expect_vector(&n[1], 1.4f, 1.5f, 1.6f, 32);
711 expect_vector(&n[2], 1.7f, 1.8f, 1.9f, 32);
712
713 IDirect3DRMMeshBuilder_Release(pMeshBuilder);
714
716}
#define D3DRMERR_NOTFOUND
Definition: d3drm.h:491
#define D3DRMERR_BADFILE
Definition: d3drm.h:494
#define IDirect3DRMMeshBuilder_GetVertexCount(p)
Definition: d3drmobj.h:2598
#define IDirect3DRMMeshBuilder_SetTextureCoordinates(p, a, b, c)
Definition: d3drmobj.h:2586
#define IDirect3DRMMeshBuilder_Scale(p, a, b, c)
Definition: d3drmobj.h:2565
#define IDirect3DRMMeshBuilder_GetTextureCoordinates(p, a, b, c)
Definition: d3drmobj.h:2591
#define IDirect3DRMMeshBuilder_Load(p, a, b, c, d, e)
Definition: d3drmobj.h:2563
#define IDirect3DRMMeshBuilder_GetFaceCount(p)
Definition: d3drmobj.h:2597
#define IDirect3DRMMeshBuilder_GetVertices(p, a, b, c, d, e, f)
Definition: d3drmobj.h:2590
#define IDirect3DRMMeshBuilder_QueryInterface(p, a, b)
Definition: d3drmobj.h:2550
#define IDirect3DRMMeshBuilder3_QueryInterface(p, a, b)
Definition: d3drmobj.h:2924
#define IDirect3DRMMeshBuilder_SetName(p, a)
Definition: d3drmobj.h:2559
GLdouble n
Definition: glext.h:7729
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
GLuint GLfloat * val
Definition: glext.h:7180
static char data_no_mesh[]
Definition: d3drm.c:295
static char data_bad_version[]
Definition: d3drm.c:288
static char data_full[]
Definition: d3drm.c:321

Referenced by START_TEST().

◆ test_MeshBuilder3()

static void test_MeshBuilder3 ( void  )
static

Definition at line 718 of file d3drm.c.

719{
720 HRESULT hr;
721 IDirect3DRM *d3drm;
722 IDirect3DRM3 *d3drm3;
723 IDirect3DRMMeshBuilder3 *pMeshBuilder3;
725 int val;
726 DWORD val1;
727 D3DVALUE valu, valv;
728
730 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
731
732 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
733 {
734 win_skip("Cannot get IDirect3DRM3 interface, hr %#lx, skipping tests\n", hr);
736 return;
737 }
738
739 hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &pMeshBuilder3);
740 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface, hr %#lx\n", hr);
741
742 test_class_name((IDirect3DRMObject *)pMeshBuilder3, "Builder");
743 test_object_name((IDirect3DRMObject *)pMeshBuilder3);
744
745 info.lpMemory = data_bad_version;
748 ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE, hr %#lx\n", hr);
749
750 info.lpMemory = data_no_mesh;
751 info.dSize = strlen(data_no_mesh);
753 ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND, hr %#lx\n", hr);
754
755 info.lpMemory = data_ok;
756 info.dSize = strlen(data_ok);
758 ok(hr == D3DRM_OK, "Cannot load mesh data, hr %#lx\n", hr);
759
761 ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
762
764 ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
765
766 hr = IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3, 0, &val1, NULL);
767 ok(hr == D3DRM_OK, "Cannot get vertices information, hr %#lx\n", hr);
768 ok(val1 == 4, "Wrong number of vertices %ld (must be 4)\n", val1);
769
770 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
771 valu = 1.23f;
772 valv = 3.21f;
773 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv);
774 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
775 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
776 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
777 valu = 1.23f;
778 valv = 3.21f;
779 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 1, &valu, &valv);
780 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
781 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
782 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
783 valu = 1.23f;
784 valv = 3.21f;
785 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 2, &valu, &valv);
786 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
787 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
788 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
789 valu = 1.23f;
790 valv = 3.21f;
791 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 3, &valu, &valv);
792 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
793 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
794 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
795 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 4, &valu, &valv);
796 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr);
797
798 valu = 1.23f;
799 valv = 3.21f;
800 hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 0, valu, valv);
801 ok(hr == D3DRM_OK, "Cannot set texture coordinates, hr %#lx\n", hr);
802 hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 4, valu, valv);
803 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr);
804
805 valu = 0.0f;
806 valv = 0.0f;
807 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv);
808 ok(hr == D3DRM_OK, "Cannot get texture coordinates, hr %#lx\n", hr);
809 ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu);
810 ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv);
811
812 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3);
813 IDirect3DRM3_Release(d3drm3);
815}
#define IDirect3DRMMeshBuilder3_SetTextureCoordinates(p, a, b, c)
Definition: d3drmobj.h:2961
#define IDirect3DRMMeshBuilder3_GetTextureCoordinates(p, a, b, c)
Definition: d3drmobj.h:2966

Referenced by START_TEST().

◆ test_object()

static void test_object ( void  )
static

Definition at line 1600 of file d3drm.c.

1601{
1602 static const struct
1603 {
1605 REFIID iid;
1606 BOOL takes_d3drm_ref;
1607 }
1608 tests[] =
1609 {
1610 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice },
1611 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice2 },
1612 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice3 },
1613 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMWinDevice },
1614 { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture },
1615 { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture2 },
1616 { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture3 },
1617 { &CLSID_CDirect3DRMViewport, &IID_IDirect3DRMViewport },
1618 { &CLSID_CDirect3DRMViewport, &IID_IDirect3DRMViewport2 },
1619 { &CLSID_CDirect3DRMFace, &IID_IDirect3DRMFace },
1620 { &CLSID_CDirect3DRMFace, &IID_IDirect3DRMFace2 },
1621 { &CLSID_CDirect3DRMMeshBuilder, &IID_IDirect3DRMMeshBuilder, TRUE },
1622 { &CLSID_CDirect3DRMMeshBuilder, &IID_IDirect3DRMMeshBuilder2, TRUE },
1623 { &CLSID_CDirect3DRMMeshBuilder, &IID_IDirect3DRMMeshBuilder3, TRUE },
1624 { &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame, TRUE },
1625 { &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame2, TRUE },
1626 { &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame3, TRUE },
1627 { &CLSID_CDirect3DRMLight, &IID_IDirect3DRMLight, TRUE },
1628 { &CLSID_CDirect3DRMMaterial, &IID_IDirect3DRMMaterial, TRUE },
1629 { &CLSID_CDirect3DRMMaterial, &IID_IDirect3DRMMaterial2, TRUE },
1630 { &CLSID_CDirect3DRMMesh, &IID_IDirect3DRMMesh, TRUE },
1631 { &CLSID_CDirect3DRMAnimation, &IID_IDirect3DRMAnimation, TRUE },
1632 { &CLSID_CDirect3DRMAnimation, &IID_IDirect3DRMAnimation2, TRUE },
1633 { &CLSID_CDirect3DRMWrap, &IID_IDirect3DRMWrap },
1634 };
1635 IDirect3DRM *d3drm1;
1636 IDirect3DRM2 *d3drm2;
1637 IDirect3DRM3 *d3drm3;
1638 IUnknown *unknown = (IUnknown *)0xdeadbeef;
1639 HRESULT hr;
1640 ULONG ref1, ref2, ref3, ref4;
1641 int i;
1642
1643 hr = Direct3DRMCreate(&d3drm1);
1644 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
1645 ref1 = get_refcount((IUnknown *)d3drm1);
1646 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
1647 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
1648 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
1649 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
1650
1651 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_DirectDraw, NULL, &IID_IDirectDraw, (void **)&unknown);
1652 ok(hr == CLASSFACTORY_E_FIRST, "Expected hr == CLASSFACTORY_E_FIRST, got %#lx.\n", hr);
1653 ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
1654
1655 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1656 {
1657 winetest_push_context("Test %u", i);
1658
1659 unknown = (IUnknown *)0xdeadbeef;
1660 hr = IDirect3DRM_CreateObject(d3drm1, NULL, NULL, tests[i].iid, (void **)&unknown);
1661 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1662 ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
1663 unknown = (IUnknown *)0xdeadbeef;
1664 hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, NULL, (void **)&unknown);
1665 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1666 ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
1668 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1669
1670 hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, tests[i].iid, (void **)&unknown);
1671 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
1672 if (SUCCEEDED(hr))
1673 {
1674 ref2 = get_refcount((IUnknown *)d3drm1);
1675 if (tests[i].takes_d3drm_ref)
1676 ok(ref2 > ref1, "Unexpected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1677 else
1678 ok(ref2 == ref1, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1679
1680 ref3 = get_refcount((IUnknown *)d3drm2);
1681 ok(ref3 == ref1, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
1682 ref4 = get_refcount((IUnknown *)d3drm3);
1683 ok(ref4 == ref1, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1684 IUnknown_Release(unknown);
1685 ref2 = get_refcount((IUnknown *)d3drm1);
1686 ok(ref2 == ref1, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1687 ref3 = get_refcount((IUnknown *)d3drm2);
1688 ok(ref3 == ref1, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
1689 ref4 = get_refcount((IUnknown *)d3drm3);
1690 ok(ref4 == ref1, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1691
1692 /* test Add/Destroy callbacks */
1694
1695 hr = IDirect3DRM2_CreateObject(d3drm2, tests[i].clsid, NULL, tests[i].iid, (void **)&unknown);
1696 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
1697 ref2 = get_refcount((IUnknown *)d3drm1);
1698 if (tests[i].takes_d3drm_ref)
1699 ok(ref2 > ref1, "Unexpected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1700 else
1701 ok(ref2 == ref1, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1702 ref3 = get_refcount((IUnknown *)d3drm2);
1703 ok(ref3 == ref1, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
1704 ref4 = get_refcount((IUnknown *)d3drm3);
1705 ok(ref4 == ref1, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1706 IUnknown_Release(unknown);
1707 ref2 = get_refcount((IUnknown *)d3drm1);
1708 ok(ref2 == ref1, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1709 ref3 = get_refcount((IUnknown *)d3drm2);
1710 ok(ref3 == ref1, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
1711 ref4 = get_refcount((IUnknown *)d3drm3);
1712 ok(ref4 == ref1, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1713
1714 hr = IDirect3DRM3_CreateObject(d3drm3, tests[i].clsid, NULL, tests[i].iid, (void **)&unknown);
1715 ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr);
1716 ref2 = get_refcount((IUnknown *)d3drm1);
1717 if (tests[i].takes_d3drm_ref)
1718 ok(ref2 > ref1, "Unexpected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1719 else
1720 ok(ref2 == ref1, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1721 ref3 = get_refcount((IUnknown *)d3drm2);
1722 ok(ref3 == ref1, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
1723 ref4 = get_refcount((IUnknown *)d3drm3);
1724 ok(ref4 == ref1, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1725 IUnknown_Release(unknown);
1726 ref2 = get_refcount((IUnknown *)d3drm1);
1727 ok(ref2 == ref1, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
1728 ref3 = get_refcount((IUnknown *)d3drm2);
1729 ok(ref3 == ref1, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
1730 ref4 = get_refcount((IUnknown *)d3drm3);
1731 ok(ref4 == ref1, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1732 }
1733
1735 }
1736
1737 IDirect3DRM_Release(d3drm1);
1738 IDirect3DRM2_Release(d3drm2);
1739 IDirect3DRM3_Release(d3drm3);
1740}
static void test_destroy_callback(unsigned int test_idx, REFCLSID clsid, REFIID iid)
Definition: d3drm.c:1498
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define CLASSFACTORY_E_FIRST
Definition: winerror.h:3770

Referenced by START_TEST(), and test_CoGetCallContext().

◆ test_object_name_()

static void test_object_name_ ( unsigned int  line,
IDirect3DRMObject *  object 
)
static

Definition at line 214 of file d3drm.c.

215{
216 char name[64] = {0};
217 HRESULT hr;
218 DWORD size;
219
221 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
222
223 name[0] = 0x1f;
225 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
226 ok_(__FILE__, line)(name[0] == 0x1f, "Unexpected buffer contents, %#x.\n", name[0]);
227
228 /* Name is not set yet. */
229 size = 100;
231 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
232 ok_(__FILE__, line)(size == 0, "Unexpected size %lu.\n", size);
233
234 size = sizeof(name);
235 name[0] = 0x1f;
237 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
238 ok_(__FILE__, line)(size == 0, "Unexpected size %lu.\n", size);
239 ok_(__FILE__, line)(name[0] == 0, "Unexpected name \"%s\".\n", name);
240
241 size = 0;
242 name[0] = 0x1f;
244 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
245 ok_(__FILE__, line)(size == 0, "Unexpected size %lu.\n", size);
246 ok_(__FILE__, line)(name[0] == 0x1f, "Unexpected name \"%s\".\n", name);
247
249 ok_(__FILE__, line)(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
250
251 hr = IDirect3DRMObject_SetName(object, "name");
252 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to set a name, hr %#lx.\n", hr);
253
254 size = 0;
256 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
257 ok_(__FILE__, line)(size == strlen("name") + 1, "Unexpected size %lu.\n", size);
258
259 size = strlen("name") + 1;
261 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
262 ok_(__FILE__, line)(size == strlen("name") + 1, "Unexpected size %lu.\n", size);
263 ok_(__FILE__, line)(!strcmp(name, "name"), "Unexpected name \"%s\".\n", name);
264
265 size = 2;
266 name[0] = 0x1f;
268 ok_(__FILE__, line)(hr == E_INVALIDARG, "Failed to get object name, hr %#lx.\n", hr);
269 ok_(__FILE__, line)(size == 2, "Unexpected size %lu.\n", size);
270 ok_(__FILE__, line)(name[0] == 0x1f, "Got unexpected name \"%s\".\n", name);
271
273 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to set object name, hr %#lx.\n", hr);
274
275 size = 1;
277 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
278 ok_(__FILE__, line)(size == 0, "Unexpected size %lu.\n", size);
279
280 size = 1;
281 name[0] = 0x1f;
283 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#lx.\n", hr);
284 ok_(__FILE__, line)(size == 0, "Unexpected size %lu.\n", size);
285 ok_(__FILE__, line)(name[0] == 0, "Got unexpected name \"%s\".\n", name);
286}
#define IDirect3DRMObject_GetName(p, a, b)
Definition: d3drmobj.h:228
#define IDirect3DRMObject_SetName(p, a)
Definition: d3drmobj.h:227

◆ test_qi()

static void test_qi ( const char *  test_name,
IUnknown *  base_iface,
REFIID  refcount_iid,
const struct qi_test *  tests,
UINT  entry_count 
)
static

Definition at line 3628 of file d3drm.c.

3630{
3631 ULONG refcount, expected_refcount;
3632 IUnknown *iface1, *iface2;
3633 HRESULT hr;
3634 UINT i, j;
3635
3636 for (i = 0; i < entry_count; ++i)
3637 {
3638 hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface1);
3639 ok(hr == tests[i].hr, "Got hr %#lx for test \"%s\" %u.\n", hr, test_name, i);
3640 if (SUCCEEDED(hr))
3641 {
3642 for (j = 0; j < entry_count; ++j)
3643 {
3644 hr = IUnknown_QueryInterface(iface1, tests[j].iid, (void **)&iface2);
3645 ok(hr == tests[j].hr, "Got hr %#lx for test \"%s\" %u, %u.\n", hr, test_name, i, j);
3646 if (SUCCEEDED(hr))
3647 {
3648 expected_refcount = 0;
3649 if (IsEqualGUID(refcount_iid, tests[j].refcount_iid))
3650 ++expected_refcount;
3651 if (IsEqualGUID(tests[i].refcount_iid, tests[j].refcount_iid))
3652 ++expected_refcount;
3653 refcount = IUnknown_Release(iface2);
3654 ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, %u, expected %lu.\n",
3655 refcount, test_name, i, j, expected_refcount);
3656 if (tests[i].vtable_iid && tests[j].vtable_iid && IsEqualGUID(tests[i].vtable_iid, tests[j].vtable_iid))
3657 ok(iface1 == iface2,
3658 "Expected iface1 == iface2 for test \"%s\" %u, %u. Got iface1 = %p, iface 2 = %p.\n",
3659 test_name, i, j, iface1, iface2);
3660 else if (tests[i].vtable_iid && tests[j].vtable_iid)
3661 ok(iface1 != iface2,
3662 "Expected iface1 != iface2 for test \"%s\" %u, %u. Got iface1 == iface2 == %p.\n",
3663 test_name, i, j, iface1);
3664 }
3665 }
3666
3667 expected_refcount = 0;
3668 if (IsEqualGUID(refcount_iid, tests[i].refcount_iid))
3669 ++expected_refcount;
3670 refcount = IUnknown_Release(iface1);
3671 ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, expected %lu.\n",
3672 refcount, test_name, i, expected_refcount);
3673 }
3674 }
3675}
static const char * test_name
Definition: run.c:194

Referenced by test_animation_qi(), test_d3drm_qi(), test_device_qi(), test_frame_qi(), test_texture_qi(), test_viewport_qi(), and test_wrap_qi().

◆ test_Texture()

static void test_Texture ( void  )
static

Definition at line 2700 of file d3drm.c.

2701{
2702 HRESULT hr;
2703 IDirect3DRM *d3drm1;
2704 IDirect3DRM2 *d3drm2;
2705 IDirect3DRM3 *d3drm3;
2706 IDirect3DRMTexture *texture1;
2707 IDirect3DRMTexture2 *texture2;
2708 IDirect3DRMTexture3 *texture3;
2709 IDirectDrawSurface *surface;
2710 LONG decalx, decaly;
2711 DWORD colors, shades;
2712 BOOL transparency;
2714
2715 D3DRMIMAGE initimg =
2716 {
2717 2, 2, 1, 1, 32,
2718 TRUE, 2 * sizeof(DWORD), NULL, NULL,
2719 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
2720 },
2721 testimg =
2722 {
2723 0, 0, 0, 0, 0,
2724 TRUE, 0, (void *)0xcafebabe, NULL,
2725 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
2726 },
2727 testimg_palette =
2728 {
2729 2, 2, 1, 1, 32,
2730 FALSE, 2 * sizeof(DWORD), (void *)0xcafebabe, NULL,
2731 0x00000000, 0x00000000, 0x00000000, 0, 2, (void *)0xcafebabe
2732 },
2733 *d3drm_img = NULL;
2734
2735 DWORD pixel[4] = { 20000, 30000, 10000, 0 };
2736 ULONG ref1, ref2, ref3, ref4;
2737
2738 hr = Direct3DRMCreate(&d3drm1);
2739 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
2740 ref1 = get_refcount((IUnknown *)d3drm1);
2741
2742 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
2743 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
2744
2745 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
2746 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
2747
2748 /* Test NULL params */
2749 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
2750 hr = IDirect3DRM_CreateTexture(d3drm1, NULL, &texture1);
2751 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2752 ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
2754 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2755
2756 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
2757 hr = IDirect3DRM2_CreateTexture(d3drm2, NULL, &texture2);
2758 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2759 ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
2761 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2762
2763 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
2764 hr = IDirect3DRM3_CreateTexture(d3drm3, NULL, &texture3);
2765 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2766 ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
2768 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2769
2770 /* Tests for validation of D3DRMIMAGE struct */
2771 hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);
2772 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr);
2773 hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);
2774 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr);
2775 hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
2776 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr);
2780
2781 testimg.rgb = 0;
2782 testimg.palette = (void *)0xdeadbeef;
2783 testimg.palette_size = 0x39;
2784 hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);
2785 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr);
2786 hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);
2787 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr);
2788 hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
2789 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr);
2793
2794 /* Just palette set */
2795 hr = IDirect3DRM_CreateTexture(d3drm1, &testimg_palette, &texture1);
2796 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr);
2797 hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg_palette, &texture2);
2798 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr);
2799 hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg_palette, &texture3);
2800 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr);
2804
2805 initimg.rgb = 0;
2806 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
2807 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2808 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2809 ok(!texture1, "Expected texture == NULL, got %p.\n", texture1);
2810 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
2811 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2812 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2813 ok(!texture2, "Expected texture == NULL, got %p.\n", texture2);
2814 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
2815 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2816 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2817 ok(!texture3, "Expected texture == NULL, got %p.\n", texture3);
2818 initimg.rgb = 1;
2819 initimg.red_mask = 0;
2820 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2821 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2822 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2823 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2824 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2825 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2826 initimg.red_mask = 0x000000ff;
2827 initimg.green_mask = 0;
2828 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2829 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2830 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2831 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2832 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2833 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2834 initimg.green_mask = 0x0000ff00;
2835 initimg.blue_mask = 0;
2836 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2837 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2838 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2839 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2840 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2841 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2842 initimg.blue_mask = 0x00ff0000;
2843 initimg.buffer1 = NULL;
2844 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2845 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2846 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2847 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2848 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2849 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2850
2851 initimg.buffer1 = &pixel;
2852 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2853 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr);
2854 ref2 = get_refcount((IUnknown *)d3drm1);
2855 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
2856 ref3 = get_refcount((IUnknown *)d3drm2);
2857 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
2858 ref4 = get_refcount((IUnknown *)d3drm3);
2859 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
2860 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2861 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr);
2862 ref2 = get_refcount((IUnknown *)d3drm1);
2863 ok(ref2 > ref1 + 1, "expected ref2 > (ref1 + 1), got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
2864 ref3 = get_refcount((IUnknown *)d3drm2);
2865 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
2866 ref4 = get_refcount((IUnknown *)d3drm3);
2867 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
2868 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2869 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr);
2870 ref2 = get_refcount((IUnknown *)d3drm1);
2871 ok(ref2 > ref1 + 2, "expected ref2 > (ref1 + 2), got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
2872 ref3 = get_refcount((IUnknown *)d3drm2);
2873 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
2874 ref4 = get_refcount((IUnknown *)d3drm3);
2875 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
2876
2877 /* Created from image, GetSurface() does not work. */
2878 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, NULL);
2879 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2880
2881 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, &surface);
2882 ok(hr == D3DRMERR_NOTCREATEDFROMDDS, "Unexpected hr %#lx.\n", hr);
2883
2884 /* Test all failures together */
2885 test_class_name((IDirect3DRMObject *)texture1, "Texture");
2886 test_class_name((IDirect3DRMObject *)texture2, "Texture");
2887 test_class_name((IDirect3DRMObject *)texture3, "Texture");
2888 test_object_name((IDirect3DRMObject *)texture1);
2889 test_object_name((IDirect3DRMObject *)texture2);
2890 test_object_name((IDirect3DRMObject *)texture3);
2891
2892 hr = IDirect3DRMTexture_GetDecalOrigin(texture1, &decalx, &decaly);
2893 ok(hr == S_OK, "got %#lx.\n", hr);
2894 ok(decalx == 0, "got %ld.\n", decalx);
2895 ok(decaly == 0, "got %ld.\n", decaly);
2896
2897 hr = IDirect3DRMTexture_SetDecalOrigin(texture1, 1, 1);
2898 ok(hr == S_OK, "got %#lx.\n", hr);
2899
2900 hr = IDirect3DRMTexture_GetDecalOrigin(texture1, &decalx, &decaly);
2901 ok(hr == S_OK, "got %#lx.\n", hr);
2902 ok(decalx == 1, "got %ld.\n", decalx);
2903 ok(decaly == 1, "got %ld.\n", decaly);
2904
2905 hr = IDirect3DRMTexture_SetDecalOrigin(texture1, 0, 0);
2906 ok(hr == S_OK, "got %#lx.\n", hr);
2907
2908 colors = IDirect3DRMTexture_GetColors(texture1);
2909 ok(colors == 8, "got %ld.\n", colors);
2910
2911 hr = IDirect3DRMTexture_SetColors(texture1, 256);
2912 ok(hr == S_OK, "got %#lx.\n", hr);
2913
2914 colors = IDirect3DRMTexture_GetColors(texture1);
2915 ok(colors == 256, "got %ld.\n", colors);
2916
2917 hr = IDirect3DRMTexture_SetColors(texture1, 8);
2918 ok(hr == S_OK, "got %#lx.\n", hr);
2919
2920 shades = IDirect3DRMTexture_GetShades(texture1);
2921 ok(shades == 16, "got %ld.\n", shades);
2922
2923 hr = IDirect3DRMTexture_SetShades(texture1, 8);
2924 ok(hr == S_OK, "got %#lx.\n", hr);
2925
2926 shades = IDirect3DRMTexture_GetShades(texture1);
2927 ok(shades == 8, "got %ld.\n", shades);
2928
2929 hr = IDirect3DRMTexture_SetShades(texture1, 11);
2930 ok(hr == S_OK, "got %#lx.\n", hr);
2931
2932 shades = IDirect3DRMTexture_GetShades(texture1);
2933 ok(shades == 11, "got %ld.\n", shades);
2934
2935 hr = IDirect3DRMTexture_SetShades(texture1, 8);
2936 ok(hr == S_OK, "got %#lx.\n", hr);
2937
2939 ok(hr == S_OK, "Got hr %#lx.\n", hr);
2940 ok(width == 1.0f, "Got %.8e.\n", width);
2941 ok(height == 1.0f, "Got %.8e.\n", height);
2942
2943 hr = IDirect3DRMTexture_SetDecalSize(texture1, 8.0f, 7.0f);
2944 ok(hr == S_OK, "Got hr %#lx.\n", hr);
2945
2947 ok(hr == S_OK, "Got hr %#lx.\n", hr);
2948 ok(width == 8.0f, "Got %.8e.\n", width);
2949 ok(height == 7.0f, "Got %.8e.\n", height);
2950
2951 hr = IDirect3DRMTexture_SetDecalSize(texture1, 1.0f, 1.0f);
2952 ok(hr == S_OK, "got %#lx.\n", hr);
2953
2954 transparency = IDirect3DRMTexture_GetDecalTransparency(texture1);
2955 ok(transparency == FALSE, "Got %d.\n", transparency);
2956
2958 ok(hr == S_OK, "Got hr %#lx.\n", hr);
2959
2960 transparency = IDirect3DRMTexture_GetDecalTransparency(texture1);
2961 ok(transparency == TRUE, "Got %d.\n", transparency);
2962
2964 ok(hr == S_OK, "Got hr %#lx.\n", hr);
2965
2966 d3drm_img = IDirect3DRMTexture_GetImage(texture1);
2967 ok(!!d3drm_img, "Failed to get image.\n");
2968 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
2969
2971 ref2 = get_refcount((IUnknown *)d3drm1);
2972 ok(ref2 - 2 == ref1, "expected (ref2 - 2) == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
2973 ref3 = get_refcount((IUnknown *)d3drm2);
2974 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
2975 ref4 = get_refcount((IUnknown *)d3drm3);
2976 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2977
2978 d3drm_img = NULL;
2979 d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
2980 ok(!!d3drm_img, "Failed to get image.\n");
2981 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
2982
2984 ref2 = get_refcount((IUnknown *)d3drm1);
2985 ok(ref2 - 1 == ref1, "expected (ref2 - 1) == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
2986 ref3 = get_refcount((IUnknown *)d3drm2);
2987 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
2988 ref4 = get_refcount((IUnknown *)d3drm3);
2989 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2990
2991 d3drm_img = NULL;
2992 d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
2993 ok(!!d3drm_img, "Failed to get image.\n");
2994 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
2995
2997 ref2 = get_refcount((IUnknown *)d3drm1);
2998 ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
2999 ref3 = get_refcount((IUnknown *)d3drm2);
3000 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
3001 ref4 = get_refcount((IUnknown *)d3drm3);
3002 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
3003
3004 /* InitFromImage tests */
3005 /* Tests for validation of D3DRMIMAGE struct */
3006 testimg.rgb = 1;
3007 testimg.palette = NULL;
3008 testimg.palette_size = 0;
3009 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture2,
3010 (void **)&texture2);
3011 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx.\n", hr);
3012 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture3,
3013 (void **)&texture3);
3014 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr);
3015 hr = IDirect3DRMTexture2_InitFromImage(texture2, &testimg);
3016 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 interface, hr %#lx\n", hr);
3017 hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
3018 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 interface, hr %#lx\n", hr);
3021
3022 testimg.rgb = 0;
3023 testimg.palette = (void *)0xdeadbeef;
3024 testimg.palette_size = 0x39;
3025 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture2,
3026 (void **)&texture2);
3027 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx.\n", hr);
3028 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture3,
3029 (void **)&texture3);
3030 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr);
3031 hr = IDirect3DRMTexture2_InitFromImage(texture2, &testimg);
3032 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 interface, hr %#lx\n", hr);
3033 hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
3034 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 interface, hr %#lx\n", hr);
3037
3038 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture2,
3039 (void **)&texture2);
3040 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx.\n", hr);
3041 ref2 = get_refcount((IUnknown *)texture2);
3043 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3044 ref3 = get_refcount((IUnknown *)texture2);
3045 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
3046
3047 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture3,
3048 (void **)&texture3);
3049 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr);
3050 ref2 = get_refcount((IUnknown *)texture3);
3052 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3053 ref3 = get_refcount((IUnknown *)texture3);
3054 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2, ref3);
3055
3056 initimg.rgb = 0;
3057 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3058 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3059 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3060 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3061 initimg.rgb = 1;
3062 initimg.red_mask = 0;
3063 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3064 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3065 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3066 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3067 initimg.red_mask = 0x000000ff;
3068 initimg.green_mask = 0;
3069 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3070 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3071 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3072 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3073 initimg.green_mask = 0x0000ff00;
3074 initimg.blue_mask = 0;
3075 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3076 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3077 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3078 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3079 initimg.blue_mask = 0x00ff0000;
3080 initimg.buffer1 = NULL;
3081 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3082 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3083 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3084 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
3085 initimg.buffer1 = &pixel;
3086
3087 d3drm_img = NULL;
3088 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3089 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 from image, hr %#lx.\n", hr);
3090 ref2 = get_refcount((IUnknown *)d3drm1);
3091 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
3092 ref3 = get_refcount((IUnknown *)d3drm2);
3093 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
3094 ref4 = get_refcount((IUnknown *)d3drm3);
3095 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
3096
3097 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
3098 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
3099 /* Release leaked reference to d3drm1 */
3100 IDirect3DRM_Release(d3drm1);
3101
3102 d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
3103 ok(!!d3drm_img, "Failed to get image.\n");
3104 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
3106 ref2 = get_refcount((IUnknown *)d3drm1);
3107 ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
3108 ref3 = get_refcount((IUnknown *)d3drm2);
3109 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
3110 ref4 = get_refcount((IUnknown *)d3drm3);
3111 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
3112
3113 d3drm_img = NULL;
3114 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3115 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 from image, hr %#lx.\n", hr);
3116 ref2 = get_refcount((IUnknown *)d3drm1);
3117 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1, ref2);
3118 ref3 = get_refcount((IUnknown *)d3drm2);
3119 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1, ref3);
3120 ref4 = get_refcount((IUnknown *)d3drm3);
3121 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1, ref4);
3122
3123 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
3124 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr);
3125 IDirect3DRM_Release(d3drm1);
3126
3127 d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
3128 ok(!!d3drm_img, "Failed to get image.\n");
3129 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
3131 ref2 = get_refcount((IUnknown *)d3drm1);
3132 ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1, ref2);
3133 ref3 = get_refcount((IUnknown *)d3drm2);
3134 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1, ref3);
3135 ref4 = get_refcount((IUnknown *)d3drm3);
3136 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
3137
3138 IDirect3DRM3_Release(d3drm3);
3139 IDirect3DRM2_Release(d3drm2);
3140 IDirect3DRM_Release(d3drm1);
3141}
#define D3DRMERR_NOTCREATEDFROMDDS
Definition: d3drm.h:513
#define IDirect3DRM_CreateTexture(p, a, b)
Definition: d3drm.h:120
#define IDirect3DRM2_CreateTexture(p, a, b)
Definition: d3drm.h:261
#define IDirect3DRMTexture_GetDecalSize(p, a, b)
Definition: d3drmobj.h:3254
#define IDirect3DRMTexture_SetColors(p, a)
Definition: d3drmobj.h:3247
#define IDirect3DRMTexture_GetDecalTransparency(p)
Definition: d3drmobj.h:3260
#define IDirect3DRMTexture2_InitFromImage(p, a)
Definition: d3drmobj.h:3379
#define IDirect3DRMTexture_SetDecalTransparency(p, a)
Definition: d3drmobj.h:3252
#define IDirect3DRMTexture_GetColors(p)
Definition: d3drmobj.h:3258
#define IDirect3DRMTexture_GetShades(p)
Definition: d3drmobj.h:3257
#define IDirect3DRMTexture_SetDecalSize(p, a, b)
Definition: d3drmobj.h:3249
#define IDirect3DRMTexture_GetDecalOrigin(p, a, b)
Definition: d3drmobj.h:3255
#define IDirect3DRMTexture_SetDecalOrigin(p, a, b)
Definition: d3drmobj.h:3250
#define IDirect3DRMTexture_SetShades(p, a)
Definition: d3drmobj.h:3248
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
ULONG blue_mask
Definition: d3drmdef.h:158
ULONG red_mask
Definition: d3drmdef.h:156
void * buffer1
Definition: d3drmdef.h:154
ULONG green_mask
Definition: d3drmdef.h:157

Referenced by START_TEST().

◆ test_texture_qi()

static void test_texture_qi ( void  )
static

Definition at line 6542 of file d3drm.c.

6543{
6544 static const struct qi_test tests[] =
6545 {
6546 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6547 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6548 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6549 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6550 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6551 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6552 { &IID_IDirect3DRMWinDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6553 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMTexture, S_OK },
6554 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6555 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6556 { &IID_IDirect3DRMFrame, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6557 { &IID_IDirect3DRMFrame2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6558 { &IID_IDirect3DRMFrame3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6559 { &IID_IDirect3DRMVisual, &IID_IUnknown, &IID_IDirect3DRMTexture, S_OK },
6560 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6561 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6562 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6563 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6564 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6565 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6566 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6567 { &IID_IDirect3DRMTexture, &IID_IUnknown, &IID_IDirect3DRMTexture, S_OK },
6568 { &IID_IDirect3DRMTexture2, &IID_IUnknown, &IID_IDirect3DRMTexture2, S_OK },
6569 { &IID_IDirect3DRMTexture3, &IID_IUnknown, &IID_IDirect3DRMTexture3, S_OK },
6570 { &IID_IDirect3DRMWrap, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6571 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6572 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6573 { &IID_IDirect3DRMAnimation, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6574 { &IID_IDirect3DRMAnimation2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6575 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6576 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6577 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6578 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6579 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6580 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6581 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6582 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6583 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6584 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6585 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6586 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6587 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6588 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6589 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6590 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6591 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6592 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6593 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6594 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6595 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6596 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6597 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6598 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6599 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6600 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6601 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6602 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6603 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6604 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6605 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6606 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6607 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6608 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6609 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6610 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6611 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6612 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6614 };
6615 HRESULT hr;
6616 IDirect3DRM *d3drm1;
6617 IDirect3DRM2 *d3drm2;
6618 IDirect3DRM3 *d3drm3;
6619 IDirect3DRMTexture *texture1;
6620 IDirect3DRMTexture2 *texture2;
6621 IDirect3DRMTexture3 *texture3;
6623 char *filename;
6624 BOOL check;
6625
6626 hr = Direct3DRMCreate(&d3drm1);
6627 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
6628 filename = create_bitmap(1, 1, TRUE);
6629 hr = IDirect3DRM_LoadTexture(d3drm1, filename, &texture1);
6630 ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
6631 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr);
6633 ok(SUCCEEDED(hr), "Cannot get IUnknown interface from IDirect3DRMTexture, hr %#lx\n", hr);
6635 test_qi("texture1_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
6636 IUnknown_Release(unknown);
6637
6638 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
6639 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
6640 hr = IDirect3DRM2_LoadTexture(d3drm2, filename, &texture2);
6641 ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
6643 ok(SUCCEEDED(hr), "Cannot get IUnknown interface from IDirect3DRMTexture2, hr %#lx\n", hr);
6645 test_qi("texture2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
6646 IUnknown_Release(unknown);
6647
6648 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
6649 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
6650 hr = IDirect3DRM3_LoadTexture(d3drm3, filename, &texture3);
6651 ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
6652 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr);
6654 ok(SUCCEEDED(hr), "Cannot get IUnknown interface from IDirect3DRMTexture3, hr %#lx\n", hr);
6656 test_qi("texture3_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
6657 IUnknown_Release(unknown);
6658
6659 IDirect3DRM3_Release(d3drm3);
6660 IDirect3DRM2_Release(d3drm2);
6661 IDirect3DRM_Release(d3drm1);
6663 ok(check, "Cannot delete image stored in %s (error = %ld).\n", filename, GetLastError());
6664 free(filename);
6665}
#define IDirect3DRMTexture_QueryInterface(p, a, b)
Definition: d3drmobj.h:3230
#define IDirect3DRMTexture2_QueryInterface(p, a, b)
Definition: d3drmobj.h:3346
#define check(expected, result)
Definition: dplayx.c:43
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ test_Viewport()

static void test_Viewport ( void  )
static

Definition at line 1742 of file d3drm.c.

1743{
1744 IDirect3DRMFrame3 *frame3, *d3drm_frame3, *tmp_frame3;
1745 IDirect3DRMFrame *frame, *d3drm_frame, *tmp_frame1;
1746 float field, left, top, right, bottom, front, back;
1747 D3DRMPROJECTIONTYPE projection;
1748 IDirectDrawClipper *clipper;
1749 HRESULT hr;
1750 IDirect3DRM *d3drm1;
1751 IDirect3DRM2 *d3drm2;
1752 IDirect3DRM3 *d3drm3;
1753 IDirect3DRMDevice *device1, *d3drm_device1;
1754 IDirect3DRMDevice3 *device3, *d3drm_device3;
1755 IDirect3DRMViewport *viewport;
1756 IDirect3DRMViewport2 *viewport2;
1757 IDirect3DViewport *d3d_viewport;
1758 D3DVIEWPORT vp;
1759 D3DVALUE expected_val;
1760 IDirect3DRMObject *obj, *obj2;
1761 GUID driver;
1762 HWND window;
1763 RECT rc;
1764 DWORD data, ref1, ref2, ref3, ref4;
1765 DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2, viewport_ref;
1766
1768 GetClientRect(window, &rc);
1769
1770 hr = Direct3DRMCreate(&d3drm1);
1771 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface, hr %#lx\n", hr);
1772 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
1773 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
1774 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
1775 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
1776 initial_ref1 = get_refcount((IUnknown *)d3drm1);
1777 initial_ref2 = get_refcount((IUnknown *)d3drm2);
1778 initial_ref3 = get_refcount((IUnknown *)d3drm3);
1779
1780 hr = DirectDrawCreateClipper(0, &clipper, NULL);
1781 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface, hr %#lx\n", hr);
1782
1783 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
1784 ok(hr == DD_OK, "Cannot set HWnd to Clipper, hr %#lx\n", hr);
1785
1786 memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
1787 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
1788 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr);
1789 hr = IDirect3DRMDevice3_QueryInterface(device3, &IID_IDirect3DRMDevice, (void **)&device1);
1790 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface, hr %#lx.\n", hr);
1791
1792 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame);
1793 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
1794 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &tmp_frame1);
1795 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1796 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
1797 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface, hr %#lx.\n", hr);
1798 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &tmp_frame3);
1799 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1800
1801 ref1 = get_refcount((IUnknown *)d3drm1);
1802 ref2 = get_refcount((IUnknown *)d3drm2);
1803 ref3 = get_refcount((IUnknown *)d3drm3);
1804 device_ref = get_refcount((IUnknown *)device1);
1805 frame_ref = get_refcount((IUnknown *)frame);
1806
1807 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, 0, 0, 0, 0, &viewport);
1808 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr);
1809 ref4 = get_refcount((IUnknown *)d3drm1);
1810 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1811 ref4 = get_refcount((IUnknown *)d3drm2);
1812 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
1813 ref4 = get_refcount((IUnknown *)d3drm3);
1814 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
1815 ref4 = get_refcount((IUnknown *)device1);
1816 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
1817 ref4 = get_refcount((IUnknown *)frame);
1818 ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
1819
1820 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
1821 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr);
1822 ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1);
1823 IDirect3DRMDevice_Release(d3drm_device1);
1824
1826 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
1828 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1829 ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame);
1831
1832 hr = IDirect3DRMViewport_SetCamera(viewport, tmp_frame1);
1833 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1835 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1836 ok(d3drm_frame == tmp_frame1, "Got unexpected frame %p, expected %p.\n", d3drm_frame, tmp_frame1);
1838
1840 ref4 = get_refcount((IUnknown *)d3drm1);
1841 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1842 ref4 = get_refcount((IUnknown *)d3drm2);
1843 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
1844 ref4 = get_refcount((IUnknown *)d3drm3);
1845 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
1846 ref4 = get_refcount((IUnknown *)device1);
1847 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
1848 ref4 = get_refcount((IUnknown *)frame);
1849 ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
1850
1851 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, 0, 0, 0, 0, &viewport);
1852 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr);
1853 ref4 = get_refcount((IUnknown *)d3drm1);
1854 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1855 ref4 = get_refcount((IUnknown *)d3drm2);
1856 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
1857 ref4 = get_refcount((IUnknown *)d3drm3);
1858 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
1859 ref4 = get_refcount((IUnknown *)device1);
1860 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
1861 ref4 = get_refcount((IUnknown *)frame);
1862 ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
1863
1864 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
1865 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr);
1866 ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1);
1867 IDirect3DRMDevice_Release(d3drm_device1);
1868
1870 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
1872 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1873 ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame);
1875
1876 hr = IDirect3DRMViewport_SetCamera(viewport, tmp_frame1);
1877 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1879 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1880 ok(d3drm_frame == tmp_frame1, "Got unexpected frame %p, expected %p.\n", d3drm_frame, tmp_frame1);
1882
1884 ref4 = get_refcount((IUnknown *)d3drm1);
1885 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1886 ref4 = get_refcount((IUnknown *)d3drm2);
1887 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
1888 ref4 = get_refcount((IUnknown *)d3drm3);
1889 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
1890 ref4 = get_refcount((IUnknown *)device1);
1891 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
1892 ref4 = get_refcount((IUnknown *)frame);
1893 ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
1894
1895 device_ref = get_refcount((IUnknown *)device3);
1896 frame_ref2 = get_refcount((IUnknown *)frame3);
1897
1898 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, 0, 0, 0, 0, &viewport2);
1899 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr);
1900 ref4 = get_refcount((IUnknown *)d3drm1);
1901 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1902 ref4 = get_refcount((IUnknown *)d3drm2);
1903 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
1904 ref4 = get_refcount((IUnknown *)d3drm3);
1905 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
1906 ref4 = get_refcount((IUnknown *)device3);
1907 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
1908 ref4 = get_refcount((IUnknown *)frame3);
1909 ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2, ref4);
1910
1911 hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3);
1912 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr);
1913 ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
1914 IDirect3DRMDevice3_Release(d3drm_device3);
1915
1917 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
1918 hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3);
1919 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1920 ok(frame3 == d3drm_frame3, "Expected frame returned = %p, got %p.\n", frame3, d3drm_frame3);
1921 IDirect3DRMFrame3_Release(d3drm_frame3);
1922
1923 hr = IDirect3DRMViewport2_SetCamera(viewport2, tmp_frame3);
1924 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1925 hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3);
1926 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
1927 ok(d3drm_frame3 == tmp_frame3, "Got unexpected frame %p, expected %p.\n", d3drm_frame3, tmp_frame3);
1928 IDirect3DRMFrame3_Release(d3drm_frame3);
1929
1931 ref4 = get_refcount((IUnknown *)d3drm1);
1932 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
1933 ref4 = get_refcount((IUnknown *)d3drm2);
1934 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
1935 ref4 = get_refcount((IUnknown *)d3drm3);
1936 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
1937 ref4 = get_refcount((IUnknown *)device3);
1938 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
1939 ref4 = get_refcount((IUnknown *)frame3);
1940 ok(ref4 == frame_ref2, "Expected ref4 == frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2, ref4);
1941
1942 /* Test all failures together */
1943 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1944 hr = IDirect3DRM_CreateViewport(d3drm1, NULL, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1945 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
1946 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1947 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1948 hr = IDirect3DRM_CreateViewport(d3drm1, device1, NULL, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1949 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
1950 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1951 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1952 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport);
1953 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1954 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1955 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1956 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom, &viewport);
1957 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1958 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1959 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1960 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1, &viewport);
1961 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1962 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1963 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, NULL);
1964 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1965
1966 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1967 hr = IDirect3DRM2_CreateViewport(d3drm2, NULL, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1968 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
1969 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1970 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1971 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, NULL, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1972 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
1973 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1974 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1975 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport);
1976 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1977 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1978 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1979 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom, &viewport);
1980 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1981 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1982 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1983 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1, &viewport);
1984 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1985 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1986 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, NULL);
1987 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
1988
1989 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1990 hr = IDirect3DRM3_CreateViewport(d3drm3, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
1991 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
1992 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1993 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1994 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, NULL, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
1995 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
1996 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1997 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1998 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport2);
1999 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2000 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
2001 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
2002 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom, &viewport2);
2003 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2004 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
2005 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
2006 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom + 1, &viewport2);
2007 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2008 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
2009 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, NULL);
2010 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#lx.\n", hr);
2011
2012 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
2013 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr);
2015 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2016 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2018 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2020 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2023 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2025
2027 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2028 vp.dwSize = sizeof(vp);
2030 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr);
2031 ok(vp.dwWidth == rc.right, "Expected viewport width = %lu, got %lu.\n", rc.right, vp.dwWidth);
2032 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %lu, got %lu.\n", rc.bottom, vp.dwHeight);
2033 ok(vp.dwX == rc.left, "Expected viewport X position = %lu, got %lu.\n", rc.left, vp.dwX);
2034 ok(vp.dwY == rc.top, "Expected viewport Y position = %lu, got %lu.\n", rc.top, vp.dwY);
2035 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2036 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2037 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2038 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2039 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2040 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2041 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2044
2045 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
2046 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr);
2048 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2049 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2051 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2053 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2056 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2058
2060 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2061 vp.dwSize = sizeof(vp);
2063 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr);
2064 ok(vp.dwWidth == rc.right, "Expected viewport width = %lu, got %lu.\n", rc.right, vp.dwWidth);
2065 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %lu, got %lu.\n", rc.bottom, vp.dwHeight);
2066 ok(vp.dwX == rc.left, "Expected viewport X position = %lu, got %lu.\n", rc.left, vp.dwX);
2067 ok(vp.dwY == rc.top, "Expected viewport Y position = %lu, got %lu.\n", rc.top, vp.dwY);
2068 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2069 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2070 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2071 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2072 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2073 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2074 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2077
2078 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
2079 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr);
2081 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2082 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2084 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2086 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2089 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2091
2093 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2094 vp.dwSize = sizeof(vp);
2096 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr);
2097 ok(vp.dwWidth == rc.right, "Expected viewport width = %lu, got %lu.\n", rc.right, vp.dwWidth);
2098 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %lu, got %lu.\n", rc.bottom, vp.dwHeight);
2099 ok(vp.dwX == rc.left, "Expected viewport X position = %lu, got %lu.\n", rc.left, vp.dwX);
2100 ok(vp.dwY == rc.top, "Expected viewport Y position = %lu, got %lu.\n", rc.top, vp.dwY);
2101 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2102 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2103 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2104 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2105 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2106 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2107 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2109
2110 hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMObject, (void**)&obj);
2111 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2112 ok((IDirect3DRMObject*)viewport == obj, "got object pointer %p, expected %p\n", obj, viewport);
2113
2114 hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMViewport2, (void**)&viewport2);
2115 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2116
2117 hr = IDirect3DRMViewport2_QueryInterface(viewport2, &IID_IDirect3DRMObject, (void**)&obj2);
2118 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2119 ok(obj == obj2, "got object pointer %p, expected %p\n", obj2, obj);
2120 ok((IUnknown*)viewport != (IUnknown*)viewport2, "got viewport1 %p, viewport2 %p\n", viewport, viewport2);
2121
2125
2126 test_class_name((IDirect3DRMObject *)viewport, "Viewport");
2127 test_object_name((IDirect3DRMObject *)viewport);
2128
2129 /* AppData */
2130 hr = IDirect3DRMViewport_SetAppData(viewport, 0);
2131 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2132
2133 hr = IDirect3DRMViewport_SetAppData(viewport, 0);
2134 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2135
2136 hr = IDirect3DRMViewport_SetAppData(viewport, 1);
2137 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2138
2139 hr = IDirect3DRMViewport_SetAppData(viewport, 1);
2140 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2141
2142 hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMViewport2, (void**)&viewport2);
2143 ok(hr == D3DRM_OK, "expected D3DRM_OK, hr %#lx\n", hr);
2144
2146 ok(data == 1, "got %lx\n", data);
2149
2150 /* IDirect3DRMViewport*::Init tests */
2151 ref1 = get_refcount((IUnknown *)d3drm1);
2152 ref2 = get_refcount((IUnknown *)d3drm2);
2153 ref3 = get_refcount((IUnknown *)d3drm3);
2154 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMViewport, NULL, &IID_IDirect3DRMViewport,
2155 (void **)&viewport);
2156 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface, hr %#lx.\n", hr);
2157 ref4 = get_refcount((IUnknown *)d3drm1);
2158 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2159 ref4 = get_refcount((IUnknown *)d3drm2);
2160 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
2161 ref4 = get_refcount((IUnknown *)d3drm3);
2162 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
2163
2165 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2166 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
2167 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2169 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2171 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2172 left = right = bottom = top = 10.0f;
2173 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2174 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2175 ok(left == 10.0f, "Got unexpected left %.8e.\n", left);
2176 ok(right == 10.0f, "Got unexpected right %.8e.\n", right);
2177 ok(bottom == 10.0f, "Got unexpected bottom %.8e.\n", bottom);
2178 ok(top == 10.0f, "Got unexpected top %.8e.\n", top);
2180 ok(front == -1.0f, "Got unexpected front %.8e\n", front);
2181 back = IDirect3DRMViewport_GetBack(viewport);
2182 ok(back == -1.0f, "Got unexpected back %.8e\n", back);
2183 projection = IDirect3DRMViewport_GetProjection(viewport);
2184 ok(projection == ~0u, "Got unexpected projection type %#x.\n", projection);
2185
2186 hr = IDirect3DRMViewport_SetCamera(viewport, frame);
2187 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2188 hr = IDirect3DRMViewport_SetField(viewport, 0.5f);
2189 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2190 hr = IDirect3DRMViewport_SetPlane(viewport, -0.5f, 0.5f, -0.5f, 0.5f);
2191 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2192 hr = IDirect3DRMViewport_SetFront(viewport, 1.0f);
2193 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2194 hr = IDirect3DRMViewport_SetBack(viewport, 100.0f);
2195 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2197 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2198
2199 /* Test all failures together */
2200 hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom);
2201 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2202 hr = IDirect3DRMViewport_Init(viewport, device1, NULL, rc.left, rc.top, rc.right, rc.bottom);
2203 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2204 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2205 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2206 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom);
2207 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2208 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1);
2209 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2210
2211 device_ref = get_refcount((IUnknown *)device1);
2212 frame_ref = get_refcount((IUnknown *)frame);
2213 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom);
2214 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMViewport interface, hr %#lx.\n", hr);
2215 ref4 = get_refcount((IUnknown *)d3drm1);
2216 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2217 ref4 = get_refcount((IUnknown *)d3drm2);
2218 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
2219 ref4 = get_refcount((IUnknown *)d3drm3);
2220 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
2221 ref4 = get_refcount((IUnknown *)device1);
2222 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
2223 ref4 = get_refcount((IUnknown *)frame);
2224 ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
2225
2226 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
2227 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr);
2228 ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
2229 IDirect3DRMDevice_Release(d3drm_device1);
2230
2232 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2233 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2235 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2237 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2240 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2242
2244 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2245 vp.dwSize = sizeof(vp);
2247 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr);
2248 ok(vp.dwWidth == rc.right, "Expected viewport width = %lu, got %lu.\n", rc.right, vp.dwWidth);
2249 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %lu, got %lu.\n", rc.bottom, vp.dwHeight);
2250 ok(vp.dwX == rc.left, "Expected viewport X position = %lu, got %lu.\n", rc.left, vp.dwX);
2251 ok(vp.dwY == rc.top, "Expected viewport Y position = %lu, got %lu.\n", rc.top, vp.dwY);
2252 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2253 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2254 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2255 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2256 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2257 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2258 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2260
2262 ok(field == 0.5f, "Got unexpected field %.8e.\n", field);
2263 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2264 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2265 ok(left == -0.5f, "Got unexpected left %.8e.\n", left);
2266 ok(right == 0.5f, "Got unexpected right %.8e.\n", right);
2267 ok(bottom == -0.5f, "Got unexpected bottom %.8e.\n", bottom);
2268 ok(top == 0.5f, "Got unexpected top %.8e.\n", top);
2270 ok(front == 1.0f, "Got unexpected front %.8e.\n", front);
2271 back = IDirect3DRMViewport_GetBack(viewport);
2272 ok(back == 100.0f, "Got unexpected back %.8e.\n", back);
2273 projection = IDirect3DRMViewport_GetProjection(viewport);
2274 ok(projection == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %#x.\n", projection);
2275
2276 hr = IDirect3DRMViewport_SetField(viewport, 1.0f);
2277 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2279 ok(field == 1.0f, "Got unexpected field %.8e.\n", field);
2280 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2281 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2282 ok(left == -1.0f, "Got unexpected left %.8e.\n", left);
2283 ok(right == 1.0f, "Got unexpected right %.8e.\n", right);
2284 ok(bottom == -1.0f, "Got unexpected bottom %.8e.\n", bottom);
2285 ok(top == 1.0f, "Got unexpected top %.8e.\n", top);
2286
2287 hr = IDirect3DRMViewport_SetPlane(viewport, 5.0f, 3.0f, 2.0f, 0.0f);
2288 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2290 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2291 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2292 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2293 ok(left == 5.0f, "Got unexpected left %.8e.\n", left);
2294 ok(right == 3.0f, "Got unexpected right %.8e.\n", right);
2295 ok(bottom == 2.0f, "Got unexpected bottom %.8e.\n", bottom);
2296 ok(top == 0.0f, "Got unexpected top %.8e.\n", top);
2297 hr = IDirect3DRMViewport_SetFront(viewport, 2.0f);
2298 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2300 ok(front == 2.0f, "Got unexpected front %.8e.\n", front);
2301 hr = IDirect3DRMViewport_SetBack(viewport, 200.0f);
2302 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2303 back = IDirect3DRMViewport_GetBack(viewport);
2304 ok(back == 200.0f, "Got unexpected back %.8e.\n", back);
2306 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2307 projection = IDirect3DRMViewport_GetProjection(viewport);
2308 ok(projection == D3DRMPROJECT_ORTHOGRAPHIC, "Got unexpected projection type %#x.\n", projection);
2309
2310 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom);
2311 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2313 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2315 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2317 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2318 hr = IDirect3DRMViewport_SetField(viewport, 0.0f);
2319 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2320 hr = IDirect3DRMViewport_SetField(viewport, -1.0f);
2321 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2322 hr = IDirect3DRMViewport_SetFront(viewport, 0.0f);
2323 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2324 hr = IDirect3DRMViewport_SetFront(viewport, -1.0f);
2325 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2328 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2329 hr = IDirect3DRMViewport_SetBack(viewport, front / 2.0f);
2330 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2331
2333 ref4 = get_refcount((IUnknown *)d3drm1);
2334 todo_wine ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2335 ref4 = get_refcount((IUnknown *)d3drm2);
2336 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
2337 ref4 = get_refcount((IUnknown *)d3drm3);
2338 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
2339 ref4 = get_refcount((IUnknown *)device1);
2340 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
2341 ref4 = get_refcount((IUnknown *)frame);
2342 todo_wine ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
2343
2344 ref1 = get_refcount((IUnknown *)d3drm1);
2345 ref2 = get_refcount((IUnknown *)d3drm2);
2346 ref3 = get_refcount((IUnknown *)d3drm3);
2347 hr = IDirect3DRM3_CreateObject(d3drm2, &CLSID_CDirect3DRMViewport, NULL, &IID_IDirect3DRMViewport2,
2348 (void **)&viewport2);
2349 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx.\n", hr);
2350 ref4 = get_refcount((IUnknown *)d3drm1);
2351 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2352 ref4 = get_refcount((IUnknown *)d3drm2);
2353 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
2354 ref4 = get_refcount((IUnknown *)d3drm3);
2355 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
2356
2358 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2359 hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3);
2360 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2361 hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3);
2362 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2364 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2365 left = right = bottom = top = 10.0f;
2366 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2367 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2368 ok(left == 10.0f, "Got unexpected left %.8e.\n", left);
2369 ok(right == 10.0f, "Got unexpected right %.8e.\n", right);
2370 ok(bottom == 10.0f, "Got unexpected bottom %.8e.\n", bottom);
2371 ok(top == 10.0f, "Got unexpected top %.8e.\n", top);
2373 ok(front == -1.0f, "Got unexpected front %.8e\n", front);
2374 back = IDirect3DRMViewport2_GetBack(viewport2);
2375 ok(back == -1.0f, "Got unexpected back %.8e\n", back);
2376 projection = IDirect3DRMViewport2_GetProjection(viewport2);
2377 ok(projection == ~0u, "Got unexpected projection type %#x.\n", projection);
2378
2379 hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3);
2380 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2381 hr = IDirect3DRMViewport2_SetField(viewport2, 0.5f);
2382 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2383 hr = IDirect3DRMViewport2_SetPlane(viewport2, -0.5f, 0.5f, -0.5f, 0.5f);
2384 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2385 hr = IDirect3DRMViewport2_SetFront(viewport2, 1.0f);
2386 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2387 hr = IDirect3DRMViewport2_SetBack(viewport2, 100.0f);
2388 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2390 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#lx.\n", hr);
2391
2392 hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom);
2393 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2394 hr = IDirect3DRMViewport2_Init(viewport2, device3, NULL, rc.left, rc.top, rc.right, rc.bottom);
2395 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2396 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2397 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2398 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom);
2399 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2400 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom + 1);
2401 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2402
2403 device_ref = get_refcount((IUnknown *)device3);
2404 frame_ref2 = get_refcount((IUnknown *)frame3);
2405 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom);
2406 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMViewport2 interface, hr %#lx.\n", hr);
2407 ref4 = get_refcount((IUnknown *)device3);
2408 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
2409 ref4 = get_refcount((IUnknown *)frame3);
2410 ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2, ref4);
2411
2412 hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3);
2413 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr);
2414 ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
2415 IDirect3DRMDevice3_Release(d3drm_device3);
2416
2418 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2419 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2421 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2423 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2426 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4, viewport_ref);
2428
2430 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
2431 vp.dwSize = sizeof(vp);
2433 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr);
2434 ok(vp.dwWidth == rc.right, "Expected viewport width = %lu, got %lu.\n", rc.right, vp.dwWidth);
2435 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %lu, got %lu.\n", rc.bottom, vp.dwHeight);
2436 ok(vp.dwX == rc.left, "Expected viewport X position = %lu, got %lu.\n", rc.left, vp.dwX);
2437 ok(vp.dwY == rc.top, "Expected viewport Y position = %lu, got %lu.\n", rc.top, vp.dwY);
2438 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2439 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2440 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2441 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2442 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2443 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2444 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2446
2448 ok(field == 0.5f, "Got unexpected field %.8e.\n", field);
2449 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2450 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2451 ok(left == -0.5f, "Got unexpected left %.8e.\n", left);
2452 ok(right == 0.5f, "Got unexpected right %.8e.\n", right);
2453 ok(bottom == -0.5f, "Got unexpected bottom %.8e.\n", bottom);
2454 ok(top == 0.5f, "Got unexpected top %.8e.\n", top);
2456 ok(front == 1.0f, "Got unexpected front %.8e.\n", front);
2457 back = IDirect3DRMViewport2_GetBack(viewport2);
2458 ok(back == 100.0f, "Got unexpected back %.8e.\n", back);
2459 projection = IDirect3DRMViewport2_GetProjection(viewport2);
2460 ok(projection == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %#x.\n", projection);
2461
2462 hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f);
2463 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2465 ok(field == 1.0f, "Got unexpected field %.8e.\n", field);
2466 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2467 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2468 ok(left == -1.0f, "Got unexpected left %.8e.\n", left);
2469 ok(right == 1.0f, "Got unexpected right %.8e.\n", right);
2470 ok(bottom == -1.0f, "Got unexpected bottom %.8e.\n", bottom);
2471 ok(top == 1.0f, "Got unexpected top %.8e.\n", top);
2472
2473 hr = IDirect3DRMViewport2_SetPlane(viewport2, 5.0f, 3.0f, 2.0f, 0.0f);
2474 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2476 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2477 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2478 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2479 ok(left == 5.0f, "Got unexpected left %.8e.\n", left);
2480 ok(right == 3.0f, "Got unexpected right %.8e.\n", right);
2481 ok(bottom == 2.0f, "Got unexpected bottom %.8e.\n", bottom);
2482 ok(top == 0.0f, "Got unexpected top %.8e.\n", top);
2483 hr = IDirect3DRMViewport2_SetFront(viewport2, 2.0f);
2484 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2486 ok(front == 2.0f, "Got unexpected front %.8e.\n", front);
2487 hr = IDirect3DRMViewport2_SetBack(viewport2, 200.0f);
2488 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2489 back = IDirect3DRMViewport2_GetBack(viewport2);
2490 ok(back == 200.0f, "Got unexpected back %.8e.\n", back);
2492 ok(hr == D3DRM_OK, "Got unexpected hr %#lx.\n", hr);
2493 projection = IDirect3DRMViewport2_GetProjection(viewport2);
2494 ok(projection == D3DRMPROJECT_ORTHOGRAPHIC, "Got unexpected projection type %#x.\n", projection);
2495
2496 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom);
2497 ok(hr == D3DRMERR_BADOBJECT, "Unexpected hr %#lx.\n", hr);
2499 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2501 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2503 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2504 hr = IDirect3DRMViewport2_SetField(viewport2, 0.0f);
2505 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2506 hr = IDirect3DRMViewport2_SetField(viewport2, -1.0f);
2507 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2508 hr = IDirect3DRMViewport2_SetFront(viewport2, 0.0f);
2509 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2510 hr = IDirect3DRMViewport2_SetFront(viewport2, -1.0f);
2511 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2514 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2515 hr = IDirect3DRMViewport2_SetBack(viewport2, front / 2.0f);
2516 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#lx.\n", hr);
2517
2519 ref4 = get_refcount((IUnknown *)d3drm1);
2520 todo_wine ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1, ref4);
2521 ref4 = get_refcount((IUnknown *)d3drm2);
2522 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2, ref4);
2523 ref4 = get_refcount((IUnknown *)d3drm3);
2524 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3, ref4);
2525 ref4 = get_refcount((IUnknown *)device3);
2526 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref, ref4);
2527 ref4 = get_refcount((IUnknown *)frame3);
2528 todo_wine ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2, ref4);
2529
2532 ref4 = get_refcount((IUnknown *)d3drm1);
2533 ok(ref4 > initial_ref1, "Expected ref4 > initial_ref1, got initial_ref1 = %lu, ref4 = %lu.\n", initial_ref1, ref4);
2534 ref4 = get_refcount((IUnknown *)d3drm2);
2535 ok(ref4 == initial_ref2, "Expected ref4 == initial_ref2, got initial_ref2 = %lu, ref4 = %lu.\n", initial_ref2, ref4);
2536 ref4 = get_refcount((IUnknown *)d3drm3);
2537 ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %lu, ref4 = %lu.\n", initial_ref3, ref4);
2538 ref4 = get_refcount((IUnknown *)frame);
2539 ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref, ref4);
2540 ref4 = get_refcount((IUnknown *)frame3);
2541 ok(ref4 == frame_ref2, "Expected ref4 == frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2, ref4);
2542
2543 IDirect3DRMFrame3_Release(tmp_frame3);
2545 ref4 = get_refcount((IUnknown *)d3drm1);
2546 ok(ref4 > initial_ref1, "Expected ref4 > initial_ref1, got initial_ref1 = %lu, ref4 = %lu.\n", initial_ref1, ref4);
2547 ref4 = get_refcount((IUnknown *)d3drm2);
2548 ok(ref4 == initial_ref2, "Expected ref4 == initial_ref2, got initial_ref2 = %lu, ref4 = %lu.\n", initial_ref2, ref4);
2549 ref4 = get_refcount((IUnknown *)d3drm3);
2550 ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %lu, ref4 = %lu.\n", initial_ref3, ref4);
2551
2552 IDirect3DRMFrame3_Release(tmp_frame1);
2554 ref4 = get_refcount((IUnknown *)d3drm1);
2555 ok(ref4 == initial_ref1, "Expected ref4 == initial_ref1, got initial_ref1 = %lu, ref4 = %lu.\n", initial_ref1, ref4);
2556 ref4 = get_refcount((IUnknown *)d3drm2);
2557 ok(ref4 == initial_ref2, "Expected ref4 == initial_ref2, got initial_ref2 = %lu, ref4 = %lu.\n", initial_ref2, ref4);
2558 ref4 = get_refcount((IUnknown *)d3drm3);
2559 ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %lu, ref4 = %lu.\n", initial_ref3, ref4);
2560 IDirectDrawClipper_Release(clipper);
2561
2562 IDirect3DRM3_Release(d3drm3);
2563 IDirect3DRM2_Release(d3drm2);
2564 IDirect3DRM_Release(d3drm1);
2566}
#define IDirect3DViewport_GetViewport(p, a)
Definition: d3d.h:679
#define IDirect3DViewport_Release(p)
Definition: d3d.h:676
#define IDirect3DRM3_CreateViewport(p, a, b, c, d, e, f, g)
Definition: d3drm.h:419
#define IDirect3DRM_CreateViewport(p, a, b, c, d, e, f, g)
Definition: d3drm.h:130
#define IDirect3DRM2_CreateViewport(p, a, b, c, d, e, f, g)
Definition: d3drm.h:271
@ D3DRMPROJECT_ORTHOGRAPHIC
Definition: d3drmdef.h:179
@ D3DRMPROJECT_PERSPECTIVE
Definition: d3drmdef.h:178
enum _D3DRMPROJECTIONTYPE D3DRMPROJECTIONTYPE
#define IDirect3DRMViewport_Release(p)
Definition: d3drmobj.h:847
#define IDirect3DRMViewport2_GetAppData(p)
Definition: d3drmobj.h:997
#define IDirect3DRMViewport_GetDirect3DViewport(p, a)
Definition: d3drmobj.h:885
#define IDirect3DRMViewport2_SetProjection(p, a)
Definition: d3drmobj.h:1010
#define IDirect3DRMViewport_QueryInterface(p, a, b)
Definition: d3drmobj.h:845
#define IDirect3DRMViewport_GetDevice(p, a)
Definition: d3drmobj.h:873
#define IDirect3DRMViewport_GetBack(p)
Definition: d3drmobj.h:882
#define IDirect3DRMViewport2_GetFront(p)
Definition: d3drmobj.h:1027
#define IDirect3DRMViewport2_QueryInterface(p, a, b)
Definition: d3drmobj.h:989
#define IDirect3DRMViewport_SetFront(p, a)
Definition: d3drmobj.h:861
#define IDirect3DRMViewport2_GetCamera(p, a)
Definition: d3drmobj.h:1016
#define IDirect3DRMViewport2_Init(p, a, b, c, d, e, f)
Definition: d3drmobj.h:1002
#define IDirect3DRMViewport_GetProjection(p)
Definition: d3drmobj.h:884
#define IDirect3DRMViewport2_GetDevice(p, a)
Definition: d3drmobj.h:1017
#define IDirect3DRMViewport_SetAppData(p, a)
Definition: d3drmobj.h:852
#define IDirect3DRMViewport_GetField(p)
Definition: d3drmobj.h:881
#define IDirect3DRMViewport_SetPlane(p, a, b, c, d)
Definition: d3drmobj.h:871
#define IDirect3DRMViewport_GetCamera(p, a)
Definition: d3drmobj.h:872
#define IDirect3DRMViewport2_SetFront(p, a)
Definition: d3drmobj.h:1005
#define IDirect3DRMViewport2_GetDirect3DViewport(p, a)
Definition: d3drmobj.h:1029
#define IDirect3DRMViewport_Init(p, a, b, c, d, e, f)
Definition: d3drmobj.h:858
#define IDirect3DRMViewport2_GetProjection(p)
Definition: d3drmobj.h:1028
#define IDirect3DRMViewport2_SetPlane(p, a, b, c, d)
Definition: d3drmobj.h:1015
#define IDirect3DRMViewport_SetProjection(p, a)
Definition: d3drmobj.h:866
#define IDirect3DRMViewport2_SetCamera(p, a)
Definition: d3drmobj.h:1009
#define IDirect3DRMViewport2_SetField(p, a)
Definition: d3drmobj.h:1007
#define IDirect3DRMViewport2_Release(p)
Definition: d3drmobj.h:991
#define IDirect3DRMViewport_GetPlane(p, a, b, c, d)
Definition: d3drmobj.h:874
#define IDirect3DRMViewport2_SetBack(p, a)
Definition: d3drmobj.h:1006
#define IDirect3DRMViewport_GetFront(p)
Definition: d3drmobj.h:883
#define IDirect3DRMViewport_SetBack(p, a)
Definition: d3drmobj.h:862
#define IDirect3DRMViewport2_GetBack(p)
Definition: d3drmobj.h:1026
#define IDirect3DRMViewport_SetField(p, a)
Definition: d3drmobj.h:863
#define IDirect3DRMViewport_SetCamera(p, a)
Definition: d3drmobj.h:865
#define IDirect3DRMViewport2_GetField(p)
Definition: d3drmobj.h:1025
#define IDirect3DRMViewport2_GetPlane(p, a, b, c, d)
Definition: d3drmobj.h:1018
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLint GLint bottom
Definition: glext.h:7726
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 * u
Definition: glfuncs.h:240
static struct address_cache * front
Definition: rpcb_clnt.c:83
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
DWORD dwHeight
Definition: d3dtypes.h:367
D3DVALUE dvMaxX
Definition: d3dtypes.h:370
D3DVALUE dvScaleY
Definition: d3dtypes.h:369
DWORD dwSize
Definition: d3dtypes.h:363
DWORD dwWidth
Definition: d3dtypes.h:366
DWORD dwX
Definition: d3dtypes.h:364
D3DVALUE dvMaxY
Definition: d3dtypes.h:371
DWORD dwY
Definition: d3dtypes.h:365
D3DVALUE dvScaleX
Definition: d3dtypes.h:368
Definition: parser.c:44

Referenced by START_TEST().

◆ test_viewport_clear1()

static void test_viewport_clear1 ( void  )
static

Definition at line 7062 of file d3drm.c.

7063{
7064 DDSCAPS caps = { DDSCAPS_ZBUFFER };
7065 IDirectDraw *ddraw;
7066 IDirectDrawClipper *clipper;
7067 IDirect3DRM *d3drm1;
7068 IDirect3DRMFrame *frame1, *camera1;
7069 IDirect3DRMDevice *device1;
7070 IDirect3DViewport *d3d_viewport;
7071 IDirect3DRMViewport *viewport1;
7072 IDirect3DDevice *d3d_device1;
7073 IDirectDrawSurface *surface, *ds, *d3drm_ds;
7074 HWND window;
7075 GUID driver = IID_IDirect3DRGBDevice;
7076 HRESULT hr;
7077 D3DCOLOR ret_color;
7078 RECT rc;
7079
7081 GetClientRect(window, &rc);
7082
7084 ok(SUCCEEDED(hr), "Cannot create IDirectDraw interface, hr %#lx.\n", hr);
7085
7086 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
7087 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
7088
7089 hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
7090 ok(SUCCEEDED(hr), "Cannot create clipper, hr %#lx.\n", hr);
7091
7092 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
7093 ok(SUCCEEDED(hr), "Cannot set HWnd to Clipper, hr %#lx\n", hr);
7094
7095 hr = Direct3DRMCreate(&d3drm1);
7096 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
7097
7098 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1);
7099 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr);
7100
7101 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame1);
7102 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
7103 hr = IDirect3DRM_CreateFrame(d3drm1, frame1, &camera1);
7104 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
7105
7106 hr = IDirect3DRM_CreateViewport(d3drm1, device1, camera1, 0, 0, rc.right,
7107 rc.bottom, &viewport1);
7108 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr);
7109
7110 /* Fetch immediate mode device and viewport */
7111 hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3d_device1);
7112 ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr);
7114 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
7115
7116 hr = IDirect3DDevice_QueryInterface(d3d_device1, &IID_IDirectDrawSurface, (void **)&surface);
7117 ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
7118
7119 ret_color = get_surface_color(surface, 320, 240);
7120 ok(compare_color(ret_color, 0, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7121
7122 /* Clear uses the scene frame's background color. */
7123 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(frame1, 1.0f, 1.0f, 1.0f);
7124 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx\n", hr);
7125 ret_color = IDirect3DRMFrame_GetSceneBackground(frame1);
7126 ok(ret_color == 0xffffffff, "Expected scene color returned == 0xffffffff, got %#lx.\n", ret_color);
7127 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(camera1, 0.0f, 1.0f, 0.0f);
7128 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx\n", hr);
7129 ret_color = IDirect3DRMFrame_GetSceneBackground(camera1);
7130 ok(ret_color == 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#lx.\n", ret_color);
7131
7132 CHECK_REFCOUNT(frame1, 1);
7133 hr = IDirect3DRMViewport_Clear(viewport1);
7134 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7135 ret_color = get_surface_color(surface, 320, 240);
7136 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7137 CHECK_REFCOUNT(frame1, 1);
7138
7139 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(frame1, 0.5f, 0.5f, 0.5f);
7140 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx\n", hr);
7141
7142 hr = IDirect3DRMViewport_Render(viewport1, frame1);
7143 ok(SUCCEEDED(hr), "Cannot Render, hr %#lx\n", hr);
7144
7145 ret_color = get_surface_color(surface, 320, 240);
7146 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7147
7148 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(frame1, 0.0f, 0.0f, 1.0f);
7149 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx\n", hr);
7150 ret_color = IDirect3DRMFrame_GetSceneBackground(frame1);
7151 ok(ret_color == 0xff0000ff, "Expected scene color returned == 0xff00ff00, got %#lx.\n", ret_color);
7152
7153 hr = IDirect3DRMViewport_Configure(viewport1, 0, 0, rc.right, rc.bottom);
7154 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7155 hr = IDirect3DRMViewport_Clear(viewport1);
7156 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7157 ret_color = get_surface_color(surface, 100, 200);
7158 ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7159
7160 d3d_draw_quad1(d3d_device1, d3d_viewport);
7161
7162 ret_color = get_surface_color(surface, 100, 200);
7163 ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7164
7165 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
7166 ok(SUCCEEDED(hr), "Cannot get attached depth surface, hr %#lx.\n", hr);
7167
7168 hr = IDirect3DRMViewport_Configure(viewport1, 0, 0, rc.right, rc.bottom);
7169 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7170 hr = IDirect3DRMViewport_Clear(viewport1);
7171 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7172 ret_color = get_surface_color(surface, 100, 200);
7173 ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7174
7175 /* Fill the depth surface with a value lower than the quad's depth value. */
7176 clear_depth_surface(ds, 0x7fff);
7177
7178 /* Depth test passes here */
7179 d3d_draw_quad1(d3d_device1, d3d_viewport);
7180 ret_color = get_surface_color(surface, 100, 200);
7181 ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7182 /* Depth test fails here */
7183 ret_color = get_surface_color(surface, 500, 400);
7184 ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7185
7186 /* Check what happens if we release the depth surface that d3drm created, and clear the viewport */
7187 hr = IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
7188 ok(SUCCEEDED(hr), "Cannot delete attached surface, hr %#lx.\n", hr);
7189 d3drm_ds = (IDirectDrawSurface *)0xdeadbeef;
7190 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
7191 ok(hr == DDERR_NOTFOUND, "Expected hr == DDERR_NOTFOUND, got %#lx.\n", hr);
7192 ok(d3drm_ds == NULL, "Expected NULL z-surface, got %p.\n", d3drm_ds);
7193
7194 clear_depth_surface(ds, 0x7fff);
7195 hr = IDirect3DRMViewport_Configure(viewport1, 0, 0, rc.right, rc.bottom);
7196 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7197 hr = IDirect3DRMViewport_Clear(viewport1);
7198 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7199
7200 ret_color = get_surface_color(surface, 100, 200);
7201 ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7202
7203 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
7204 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
7205 IDirectDrawSurface_Release(ds);
7206
7207 d3d_draw_quad1(d3d_device1, d3d_viewport);
7208
7209 ret_color = get_surface_color(surface, 100, 200);
7210 ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7211 ret_color = get_surface_color(surface, 500, 400);
7212 ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7213
7215 IDirectDrawSurface_Release(surface);
7216 IDirect3DDevice_Release(d3d_device1);
7217 IDirect3DRMViewport_Release(viewport1);
7219 IDirect3DRMFrame_Release(camera1);
7221 IDirect3DRM_Release(d3drm1);
7222 IDirectDrawClipper_Release(clipper);
7223 IDirectDraw_Release(ddraw);
7225}
#define IDirect3DRMViewport_Render(p, a)
Definition: d3drmobj.h:860
#define IDirect3DRMViewport_Configure(p, a, b, c, d)
Definition: d3drmobj.h:869
#define IDirect3DRMViewport_Clear(p)
Definition: d3drmobj.h:859
static void clear_depth_surface(IDirectDrawSurface *surface, DWORD value)
Definition: d3drm.c:6873
static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
Definition: d3drm.c:110
static D3DCOLOR get_surface_color(IDirectDrawSurface *surface, UINT x, UINT y)
Definition: d3drm.c:6813
static void d3d_draw_quad1(IDirect3DDevice *device, IDirect3DViewport *viewport)
Definition: d3drm.c:6983

Referenced by START_TEST().

◆ test_viewport_clear2()

static void test_viewport_clear2 ( void  )
static

Definition at line 7272 of file d3drm.c.

7273{
7274 DDSCAPS caps = { DDSCAPS_ZBUFFER };
7275 IDirect3D2 *d3d2;
7276 IDirectDraw *ddraw1;
7277 IDirectDraw2 *ddraw2;
7278 IDirectDrawClipper *clipper;
7279 IDirect3DRM *d3drm1;
7280 IDirect3DRM3 *d3drm3;
7281 IDirect3DRMFrame3 *frame3, *camera3;
7282 IDirect3DRMDevice3 *device3;
7283 IDirect3DViewport *d3d_viewport;
7284 IDirect3DRMViewport2 *viewport2;
7285 IDirect3DDevice2 *d3d_device2;
7286 IDirectDrawSurface *surface, *ds, *d3drm_ds;
7287 HWND window;
7288 GUID driver = IID_IDirect3DRGBDevice;
7289 HRESULT hr;
7290 D3DCOLOR ret_color;
7291 RECT rc;
7292
7294 GetClientRect(window, &rc);
7295
7296 hr = DirectDrawCreate(NULL, &ddraw1, NULL);
7297 ok(SUCCEEDED(hr), "Cannot create IDirectDraw interface, hr %#lx.\n", hr);
7298
7299 hr = IDirectDraw_SetCooperativeLevel(ddraw1, window, DDSCL_NORMAL);
7300 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
7301
7302 hr = IDirectDraw_CreateClipper(ddraw1, 0, &clipper, NULL);
7303 ok(SUCCEEDED(hr), "Cannot create clipper, hr %#lx.\n", hr);
7304
7305 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
7306 ok(SUCCEEDED(hr), "Cannot set HWnd to Clipper, hr %#lx.\n", hr);
7307
7308 hr = Direct3DRMCreate(&d3drm1);
7309 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
7310
7311 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
7312 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
7313
7314 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
7315 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
7316
7317 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
7318 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface, hr %#lx.\n", hr);
7319 hr = IDirect3DRM3_CreateFrame(d3drm3, frame3, &camera3);
7320 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface, hr %#lx.\n", hr);
7321
7322 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, camera3, 0, 0, rc.right,
7323 rc.bottom, &viewport2);
7324 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx.\n", hr);
7325
7326 /* Fetch immediate mode device in order to access render target and test its color. */
7327 hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3d_device2);
7328 ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr);
7329
7330 hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface);
7331 ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
7332
7333 ret_color = get_surface_color(surface, 320, 240);
7334 ok(compare_color(ret_color, 0, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7335
7336 /* Clear uses the scene frame's background color. */
7337 hr = IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3, 1.0f, 1.0f, 1.0f);
7338 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx.\n", hr);
7339 ret_color = IDirect3DRMFrame3_GetSceneBackground(frame3);
7340 ok(ret_color == 0xffffffff, "Expected scene color returned == 0xffffffff, got %#lx.\n", ret_color);
7341 hr = IDirect3DRMFrame3_SetSceneBackgroundRGB(camera3, 0.0f, 1.0f, 0.0f);
7342 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx.\n", hr);
7343 ret_color = IDirect3DRMFrame3_GetSceneBackground(camera3);
7344 ok(ret_color == 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#lx.\n", ret_color);
7345
7346 CHECK_REFCOUNT(frame3, 1);
7348 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7349 ret_color = get_surface_color(surface, 320, 240);
7350 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7351 CHECK_REFCOUNT(frame3, 1);
7352
7353 hr = IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3, 0.5f, 0.5f, 0.5f);
7354 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx\n", hr);
7355
7356 hr = IDirect3DRMViewport2_Render(viewport2, frame3);
7357 ok(SUCCEEDED(hr), "Cannot Render, hr %#lx\n", hr);
7358
7359 ret_color = get_surface_color(surface, 320, 240);
7360 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7361
7362 hr = IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3, 1.0f, 1.0f, 1.0f);
7363 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx\n", hr);
7364
7366 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr);
7367
7369 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7370
7371 /* d3drm seems to be calling BeginScene when Clear is called. */
7372 hr = IDirect3DDevice2_BeginScene(d3d_device2);
7373 todo_wine ok(hr == D3DERR_SCENE_IN_SCENE, "Expected hr == D3DERR_SCENE_IN_SCENE, got %#lx.\n", hr);
7374 hr = IDirect3DDevice2_EndScene(d3d_device2);
7375 ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
7376
7377 ret_color = get_surface_color(surface, 320, 240);
7378 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7379
7380 /* We're using d3d to draw using IDirect3DDevice2 created from d3drm. */
7381 draw_quad2(d3d_device2, d3d_viewport);
7382 ret_color = get_surface_color(surface, 320, 240);
7383 ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7384
7385 /* Without calling Configure, Clear doesn't work. */
7387 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7388 ret_color = get_surface_color(surface, 320, 240);
7389 todo_wine ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7390
7391 hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom);
7392 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7394 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7395
7396 ret_color = get_surface_color(surface, 320, 240);
7397 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7398
7399 /* Fetch attached depth surface and see if viewport clears it if it's detached from the render target. */
7400 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
7401 ok(SUCCEEDED(hr), "Cannot get attached depth surface, hr %#lx.\n", hr);
7402
7403 clear_depth_surface(ds, 0x39);
7404 draw_quad2(d3d_device2, d3d_viewport);
7405
7406 ret_color = get_surface_color(surface, 320, 240);
7407 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7408
7409 hr = IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
7410 ok(SUCCEEDED(hr), "Cannot delete attached surface, hr %#lx.\n", hr);
7411 d3drm_ds = (IDirectDrawSurface *)0xdeadbeef;
7412 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &d3drm_ds);
7413 ok(hr == DDERR_NOTFOUND, "Expected hr == DDERR_NOTFOUND, got %#lx.\n", hr);
7414 ok(d3drm_ds == NULL, "Expected NULL z-surface, got %p.\n", d3drm_ds);
7415
7416 clear_depth_surface(ds, 0x7fff);
7417
7418 /* This version of Clear still clears the depth surface even if it's deleted from the render target. */
7419 hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom);
7420 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7422 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7423
7424 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
7425 ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
7426 ret_color = get_surface_color(surface, 320, 240);
7427 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7428
7429 draw_quad2(d3d_device2, d3d_viewport);
7430 ret_color = get_surface_color(surface, 100, 200);
7431 ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7432 ret_color = get_surface_color(surface, 500, 400);
7433 todo_wine ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7434
7435 /* Remove old draw contents */
7436 hr = IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3, 0.0f, 1.0f, 0.0f);
7437 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx.\n", hr);
7438 hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom);
7439 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7441 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7442 hr = IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3, 1.0f, 1.0f, 1.0f);
7443 ok(SUCCEEDED(hr), "Cannot set scene background RGB, hr %#lx.\n", hr);
7444
7445 /* Clear with no flags */
7446 hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom);
7447 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7448 hr = IDirect3DRMViewport2_Clear(viewport2, 0);
7449 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7450 ret_color = get_surface_color(surface, 320, 240);
7451 ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7452
7453 hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom);
7454 todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport, hr %#lx.\n", hr);
7456 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7457 ret_color = get_surface_color(surface, 320, 240);
7458 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7459
7461 IDirectDrawSurface_Release(surface);
7462 IDirectDrawSurface_Release(ds);
7463 IDirect3DDevice2_Release(d3d_device2);
7466
7467 /* Create device without depth surface attached */
7468 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
7469 ok(SUCCEEDED(hr), "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr);
7470 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D2, (void **)&d3d2);
7471 ok(SUCCEEDED(hr), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr);
7472 d3d_device2 = create_device2_without_ds(ddraw2, window);
7473 if (!d3d_device2)
7474 goto cleanup;
7475
7476 hr = IDirect3DRM3_CreateDeviceFromD3D(d3drm3, d3d2, d3d_device2, &device3);
7477 ok(SUCCEEDED(hr), "Failed to create IDirect3DRMDevice interface, hr %#lx.\n", hr);
7478 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, camera3, 0, 0, rc.right,
7479 rc.bottom, &viewport2);
7480 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx.\n", hr);
7481 hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface);
7482 ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
7483
7485 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7486 ret_color = get_surface_color(surface, 320, 240);
7487 ok(compare_color(ret_color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
7488
7490 ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
7491
7492 IDirectDrawSurface_Release(surface);
7495 IDirect3DDevice2_Release(d3d_device2);
7496
7497cleanup:
7500 IDirect3DRM3_Release(d3drm3);
7501 IDirect3DRM_Release(d3drm1);
7502 IDirectDrawClipper_Release(clipper);
7503 IDirect3D2_Release(d3d2);
7504 IDirectDraw2_Release(ddraw2);
7505 IDirectDraw_Release(ddraw1);
7507}
#define D3DERR_SCENE_IN_SCENE
Definition: d3d.h:151
#define D3DRMCLEAR_ZBUFFER
Definition: d3drmdef.h:311
#define D3DRMCLEAR_ALL
Definition: d3drmdef.h:313
#define IDirect3DRMViewport2_Configure(p, a, b, c, d)
Definition: d3drmobj.h:1013
#define IDirect3DRMFrame3_SetSceneBackgroundRGB(p, a, b, c)
Definition: d3drmobj.h:1756
#define IDirect3DRMFrame3_GetSceneBackground(p)
Definition: d3drmobj.h:1749
#define IDirect3DRMViewport2_Clear(p, a)
Definition: d3drmobj.h:1003
#define IDirect3DRMViewport2_Render(p, a)
Definition: d3drmobj.h:1004
static IDirect3DDevice2 * create_device2_without_ds(IDirectDraw2 *ddraw, HWND window)
Definition: d3drm.c:6836
static void draw_quad2(IDirect3DDevice2 *device, IDirect3DViewport *viewport)
Definition: d3drm.c:7227

Referenced by START_TEST().

◆ test_viewport_qi()

static void test_viewport_qi ( void  )
static

Definition at line 6667 of file d3drm.c.

6668{
6669 IDirect3DRM *d3drm1;
6670 IDirect3DRM2 *d3drm2;
6671 IDirect3DRM3 *d3drm3;
6672 IDirect3DRMFrame *frame1, *camera1;
6673 IDirect3DRMFrame3 *frame3, *camera3;
6674 IDirect3DRMDevice *device1;
6675 IDirect3DRMDevice3 *device3;
6676 IDirectDrawClipper *clipper;
6677 IDirect3DRMViewport *viewport1;
6678 IDirect3DRMViewport2 *viewport2;
6680 GUID driver = IID_IDirect3DRGBDevice;
6681 HRESULT hr;
6682
6683 static const struct qi_test tests[] =
6684 {
6685 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6686 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6687 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6688 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6689 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6690 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6691 { &IID_IDirect3DRMWinDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6692 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMViewport, S_OK },
6693 { &IID_IDirect3DRMViewport, &IID_IUnknown, &IID_IDirect3DRMViewport, S_OK },
6694 { &IID_IDirect3DRMViewport2, &IID_IUnknown, &IID_IDirect3DRMViewport2, S_OK },
6695 { &IID_IDirect3DRMFrame, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6696 { &IID_IDirect3DRMFrame2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6697 { &IID_IDirect3DRMFrame3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6698 { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6699 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6700 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6701 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6702 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6703 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6704 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6705 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6706 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6707 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6708 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6709 { &IID_IDirect3DRMWrap, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6710 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6711 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6712 { &IID_IDirect3DRMAnimation, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6713 { &IID_IDirect3DRMAnimation2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6714 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6715 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6716 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6717 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6718 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6719 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6720 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6721 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6722 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6723 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6724 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6725 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6726 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6727 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6728 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6729 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6730 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6731 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6732 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6733 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6734 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6735 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6736 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6737 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6738 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6739 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6740 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6741 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6742 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6743 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6744 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6745 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6746 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6747 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6748 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6749 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6750 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6751 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
6753 };
6754
6755 hr = DirectDrawCreateClipper(0, &clipper, NULL);
6756 ok(SUCCEEDED(hr), "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr);
6757
6758 hr = Direct3DRMCreate(&d3drm1);
6759 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr);
6760
6761 hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, 640, 480, &device1);
6762 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface, hr %#lx.\n", hr);
6763 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame1);
6764 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
6765 hr = IDirect3DRM_CreateFrame(d3drm1, frame1, &camera1);
6766 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr);
6767 hr = IDirect3DRM_CreateViewport(d3drm1, device1, camera1, 0, 0, 640, 480, &viewport1);
6768 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr);
6770 ok(SUCCEEDED(hr), "Cannot get IUnknown interface, hr %#lx.\n", hr);
6771 IDirect3DRMViewport_Release(viewport1);
6772 test_qi("viewport1_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
6773 IUnknown_Release(unknown);
6774
6775 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
6776 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr);
6777 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, camera1, 0, 0, 640, 480, &viewport1);
6778 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr);
6780 ok(SUCCEEDED(hr), "Cannot get IUnknown interface, hr %#lx.\n", hr);
6781 IDirect3DRMViewport_Release(viewport1);
6782 test_qi("viewport1_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
6783 IUnknown_Release(unknown);
6785 IDirect3DRMFrame_Release(camera1);
6787
6788 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
6789 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr);
6790 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, 640, 480, &device3);
6791 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr);
6792 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
6793 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface, hr %#lx\n", hr);
6794 hr = IDirect3DRM3_CreateFrame(d3drm3, frame3, &camera3);
6795 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface, hr %#lx\n", hr);
6796 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, camera3, 0, 0, 640, 480, &viewport2);
6797 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr);
6799 ok(SUCCEEDED(hr), "Cannot get IUnknown interface, hr %#lx.\n", hr);
6800 IDirect3DRMViewport_Release(viewport2);
6801 test_qi("viewport2_qi", unknown, &IID_IUnknown, tests, ARRAY_SIZE(tests));
6802 IUnknown_Release(unknown);
6806
6807 IDirectDrawClipper_Release(clipper);
6808 IDirect3DRM3_Release(d3drm3);
6809 IDirect3DRM2_Release(d3drm2);
6810 IDirect3DRM_Release(d3drm1);
6811}

Referenced by START_TEST().

◆ test_wrap()

static void test_wrap ( void  )
static

Definition at line 8127 of file d3drm.c.

8128{
8129 IDirect3DRMWrap *wrap;
8130 IDirect3DRM *d3drm1;
8131 HRESULT hr;
8132
8133 hr = Direct3DRMCreate(&d3drm1);
8134 ok(SUCCEEDED(hr), "Failed to create IDirect3DRM instance, hr %#lx.\n", hr);
8135
8136 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMWrap, NULL, &IID_IDirect3DRMWrap, (void **)&wrap);
8137 ok(SUCCEEDED(hr), "Failed to create wrap instance, hr %#lx.\n", hr);
8138
8139 test_class_name((IDirect3DRMObject *)wrap, "");
8140
8142 IDirect3DRM_Release(d3drm1);
8143}
#define IDirect3DRMWrap_Release(p)
Definition: d3drmobj.h:3590
#define wrap(journal, var)
Definition: recovery.c:207

Referenced by START_TEST().

◆ test_wrap_qi()

static void test_wrap_qi ( void  )
static

Definition at line 8145 of file d3drm.c.

8146{
8147 static const struct qi_test tests[] =
8148 {
8149 { &IID_IDirect3DRMWrap, &IID_IUnknown, &IID_IDirect3DRMWrap, S_OK },
8150 { &IID_IDirect3DRM, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8151 { &IID_IDirect3DRMDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8152 { &IID_IDirect3DRMObject, &IID_IUnknown, &IID_IDirect3DRMWrap, S_OK },
8153 { &IID_IDirect3DRMDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8154 { &IID_IDirect3DRMDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8155 { &IID_IDirect3DRMViewport, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8156 { &IID_IDirect3DRMViewport2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8157 { &IID_IDirect3DRM3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8158 { &IID_IDirect3DRM2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8159 { &IID_IDirect3DRMVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8160 { &IID_IDirect3DRMMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8161 { &IID_IDirect3DRMMeshBuilder, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8162 { &IID_IDirect3DRMMeshBuilder2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8163 { &IID_IDirect3DRMMeshBuilder3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8164 { &IID_IDirect3DRMFace, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8165 { &IID_IDirect3DRMFace2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8166 { &IID_IDirect3DRMLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8167 { &IID_IDirect3DRMTexture, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8168 { &IID_IDirect3DRMTexture2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8169 { &IID_IDirect3DRMTexture3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8170 { &IID_IDirect3DRMMaterial, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8171 { &IID_IDirect3DRMMaterial2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8172 { &IID_IDirect3DRMAnimation, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8173 { &IID_IDirect3DRMAnimation2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8174 { &IID_IDirect3DRMAnimationSet, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8175 { &IID_IDirect3DRMAnimationSet2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8176 { &IID_IDirect3DRMObjectArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8177 { &IID_IDirect3DRMDeviceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8178 { &IID_IDirect3DRMViewportArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8179 { &IID_IDirect3DRMFrameArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8180 { &IID_IDirect3DRMVisualArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8181 { &IID_IDirect3DRMLightArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8182 { &IID_IDirect3DRMPickedArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8183 { &IID_IDirect3DRMFaceArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8184 { &IID_IDirect3DRMAnimationArray, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8185 { &IID_IDirect3DRMUserVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8186 { &IID_IDirect3DRMShadow, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8187 { &IID_IDirect3DRMShadow2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8188 { &IID_IDirect3DRMInterpolator, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8189 { &IID_IDirect3DRMProgressiveMesh, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8190 { &IID_IDirect3DRMPicked2Array, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8191 { &IID_IDirect3DRMClippedVisual, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8192 { &IID_IDirectDrawClipper, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8193 { &IID_IDirectDrawSurface7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8194 { &IID_IDirectDrawSurface4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8195 { &IID_IDirectDrawSurface3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8196 { &IID_IDirectDrawSurface2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8197 { &IID_IDirectDrawSurface, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8198 { &IID_IDirect3DDevice7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8199 { &IID_IDirect3DDevice3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8200 { &IID_IDirect3DDevice2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8201 { &IID_IDirect3DDevice, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8202 { &IID_IDirect3D7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8203 { &IID_IDirect3D3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8204 { &IID_IDirect3D2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8205 { &IID_IDirect3D, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8206 { &IID_IDirectDraw7, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8207 { &IID_IDirectDraw4, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8208 { &IID_IDirectDraw3, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8209 { &IID_IDirectDraw2, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8210 { &IID_IDirectDraw, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8211 { &IID_IDirect3DLight, NULL, NULL, CLASS_E_CLASSNOTAVAILABLE },
8213 };
8214 IDirect3DRMWrap *wrap;
8215 IDirect3DRM *d3drm1;
8217 HRESULT hr;
8218
8219 hr = Direct3DRMCreate(&d3drm1);
8220 ok(SUCCEEDED(hr), "Failed to create d3drm instance, hr %#lx.\n", hr);
8221
8222 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMWrap, NULL, &IID_IDirect3DRMWrap, (void **)&wrap);
8223 ok(SUCCEEDED(hr), "Failed to create wrap instance, hr %#lx.\n", hr);
8224
8226 ok(SUCCEEDED(hr), "Failed to get IUnknown from wrap, hr %#lx.\n", hr);
8229 IUnknown_Release(unknown);
8230
8231 IDirect3DRM_Release(d3drm1);
8232}
#define IDirect3DRMWrap_QueryInterface(p, a, b)
Definition: d3drmobj.h:3588

Referenced by START_TEST().

◆ vector_eq_()

static void vector_eq_ ( unsigned int  line,
const D3DVECTOR *  left,
const D3DVECTOR *  right 
)
static

Definition at line 105 of file d3drm.c.

106{
107 expect_vector_(line, left, right->x, right->y, right->z, 0);
108}
static void expect_vector_(unsigned int line, const D3DVECTOR *v, float x, float y, float z, unsigned int ulps)
Definition: d3drm.c:94

Variable Documentation

◆ color

◆ corder

Referenced by test_destroy_callback().

◆ d3drm_corder

◆ data_bad_version

char data_bad_version[]
static
Initial value:
=
"xof 0302txt 0064\n"
"Header Object\n"
"{\n"
"1; 2; 3;\n"
"}\n"

Definition at line 288 of file d3drm.c.

Referenced by test_MeshBuilder(), and test_MeshBuilder3().

◆ data_d3drm_load

char data_d3drm_load[]
static

Definition at line 359 of file d3drm.c.

Referenced by test_d3drm_load().

◆ data_frame_mesh_materials

char data_frame_mesh_materials[]
static

Definition at line 392 of file d3drm.c.

Referenced by test_frame_mesh_materials().

◆ data_full

char data_full[]
static

Definition at line 321 of file d3drm.c.

Referenced by test_MeshBuilder().

◆ data_no_mesh

char data_no_mesh[]
static
Initial value:
=
"xof 0302txt 0064\n"
"Header Object\n"
"{\n"
"1; 0; 1;\n"
"}\n"

Definition at line 295 of file d3drm.c.

Referenced by test_MeshBuilder(), and test_MeshBuilder3().

◆ data_ok

char data_ok[]
static
Initial value:
=
"xof 0302txt 0064\n"
"Header Object\n"
"{\n"
"1; 0; 1;\n"
"}\n"
"Mesh Object\n"
"{\n"
"4;\n"
"1.0; 0.0; 0.0;,\n"
"0.0; 1.0; 0.0;,\n"
"0.0; 0.0; 1.0;,\n"
"1.0; 1.0; 1.0;;\n"
"3;\n"
"3; 0, 1, 2;,\n"
"3; 1, 2, 3;,\n"
"3; 3, 1, 2;;\n"
"}\n"

Definition at line 302 of file d3drm.c.

Referenced by test_Face(), test_MeshBuilder(), and test_MeshBuilder3().

◆ emissive

◆ face_count

◆ face_data_size

◆ 

struct { ... } groups[3]
Initial value:
= {
{ 4, 3, 3, 9, 0x4c0000ff, 30.0f, { 0.31f, 0.32f, 0.33f }, { 0.34f, 0.35f, 0.36f } },
{ 4, 2, 3, 6, 0x3300ff00, 20.0f, { 0.21f, 0.22f, 0.23f }, { 0.24f, 0.25f, 0.26f } },
{ 3, 1, 3, 3, 0x19ff0000, 10.0f, { 0.11f, 0.12f, 0.13f }, { 0.14f, 0.15f, 0.16f } }
}

◆ identity

Initial value:
= {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}

Definition at line 118 of file d3drm.c.

◆ mesh_builder

IDirect3DRMMeshBuilder* mesh_builder = NULL

Definition at line 3491 of file d3drm.c.

Referenced by clean_mesh_builder_data(), d3drm1_CreateMeshBuilder(), d3drm2_CreateMeshBuilder(), d3drm3_CreateMeshBuilder(), d3drm_create_mesh_builder_object(), d3drm_mesh_builder2_AddDestroyCallback(), d3drm_mesh_builder2_AddMeshBuilder(), d3drm_mesh_builder2_AddNormal(), d3drm_mesh_builder2_AddRef(), d3drm_mesh_builder2_AddVertex(), d3drm_mesh_builder2_CreateMesh(), d3drm_mesh_builder2_DeleteDestroyCallback(), d3drm_mesh_builder2_GetAppData(), d3drm_mesh_builder2_GetClassName(), d3drm_mesh_builder2_GetFaceCount(), d3drm_mesh_builder2_GetName(), d3drm_mesh_builder2_GetQuality(), d3drm_mesh_builder2_GetTextureCoordinates(), d3drm_mesh_builder2_GetVertexCount(), d3drm_mesh_builder2_GetVertices(), d3drm_mesh_builder2_Load(), d3drm_mesh_builder2_QueryInterface(), d3drm_mesh_builder2_Release(), d3drm_mesh_builder2_Scale(), d3drm_mesh_builder2_SetAppData(), d3drm_mesh_builder2_SetColor(), d3drm_mesh_builder2_SetColorRGB(), d3drm_mesh_builder2_SetMaterial(), d3drm_mesh_builder2_SetName(), d3drm_mesh_builder2_SetQuality(), d3drm_mesh_builder2_SetTexture(), d3drm_mesh_builder2_SetTextureCoordinates(), d3drm_mesh_builder3_AddDestroyCallback(), d3drm_mesh_builder3_AddMeshBuilder(), d3drm_mesh_builder3_AddNormal(), d3drm_mesh_builder3_AddRef(), d3drm_mesh_builder3_AddVertex(), d3drm_mesh_builder3_CreateMesh(), d3drm_mesh_builder3_DeleteDestroyCallback(), d3drm_mesh_builder3_GetAppData(), d3drm_mesh_builder3_GetFaceCount(), d3drm_mesh_builder3_GetName(), d3drm_mesh_builder3_GetNormalCount(), d3drm_mesh_builder3_GetNormals(), d3drm_mesh_builder3_GetQuality(), d3drm_mesh_builder3_GetTextureCoordinates(), d3drm_mesh_builder3_GetVertexCount(), d3drm_mesh_builder3_GetVertices(), d3drm_mesh_builder3_Load(), d3drm_mesh_builder3_QueryInterface(), d3drm_mesh_builder3_Release(), d3drm_mesh_builder3_Scale(), d3drm_mesh_builder3_SetAppData(), d3drm_mesh_builder3_SetColor(), d3drm_mesh_builder3_SetColorRGB(), d3drm_mesh_builder3_SetMaterial(), d3drm_mesh_builder3_SetName(), d3drm_mesh_builder3_SetQuality(), d3drm_mesh_builder3_SetTexture(), d3drm_mesh_builder3_SetTextureCoordinates(), d3drm_mesh_builder_create(), DECLARE_INTERFACE_(), load_mesh_data(), object_load_callback_frame(), test_Frame(), and test_frame_mesh_materials().

◆ nb_objects

int nb_objects = 0
static

Definition at line 3454 of file d3drm.c.

Referenced by object_load_callback(), and test_d3drm_load().

◆ power

◆ refiids

const GUID* refiids[]
static
Initial value:
=
{
&IID_IDirect3DRMMeshBuilder,
&IID_IDirect3DRMMeshBuilder,
&IID_IDirect3DRMFrame,
&IID_IDirect3DRMMaterial
}

Definition at line 3455 of file d3drm.c.

Referenced by object_load_callback().

◆ specular

◆ vertex_count

int vertex_count

Definition at line 3528 of file d3drm.c.

Referenced by d2d_cdt_triangulate(), d2d_geometry_add_figure_outline(), d2d_path_geometry_triangulate(), d3d10_device_Draw(), d3d11_device_context_Draw(), d3d8_device_DrawIndexedPrimitive(), d3d8_device_DrawIndexedPrimitiveUP(), d3d8_device_DrawPrimitive(), d3d8_device_ProcessVertices(), d3d8_device_upload_sysmem_vertex_buffers(), d3d9_device_DrawIndexedPrimitive(), d3d9_device_DrawIndexedPrimitiveUP(), d3d9_device_DrawPrimitive(), d3d9_device_ProcessVertices(), d3d9_device_upload_sysmem_vertex_buffers(), d3d_device2_BeginIndexed(), d3d_device2_DrawIndexedPrimitive(), d3d_device2_DrawPrimitive(), d3d_device3_BeginIndexed(), d3d_device3_DrawIndexedPrimitive(), d3d_device3_DrawPrimitive(), d3d_device7_DrawIndexedPrimitive(), d3d_device7_DrawIndexedPrimitive_FPUPreserve(), d3d_device7_DrawIndexedPrimitive_FPUSetup(), d3d_device7_DrawIndexedPrimitiveStrided(), d3d_device7_DrawIndexedPrimitiveVB(), d3d_device7_DrawPrimitive(), d3d_device7_DrawPrimitive_FPUPreserve(), d3d_device7_DrawPrimitive_FPUSetup(), d3d_device7_DrawPrimitiveStrided(), d3d_device7_DrawPrimitiveVB(), d3drm_face1_GetVertices(), d3drm_face2_GetVertices(), d3drm_mesh_AddGroup(), d3drm_mesh_builder2_AddFaces(), d3drm_mesh_builder2_GetVertices(), d3drm_mesh_builder2_ReserveSpace(), d3drm_mesh_builder3_AddFaces(), d3drm_mesh_builder3_AddTriangles(), d3drm_mesh_builder3_GetGeometry(), d3drm_mesh_builder3_GetVertices(), d3drm_mesh_builder3_ReserveSpace(), d3drm_mesh_GetGroup(), D3DX10CreateMesh(), d3dx9_skin_info_Remap(), D3DXCreateMeshFVF(), D3DXCreateSkinInfo(), D3DXCreateSkinInfoFVF(), D3DXOptimizeVertices(), DECLARE_INTERFACE_(), emit_process_vertices(), set_execute_data(), test_frame_mesh_materials(), wined3d_device_context_draw(), and wined3d_device_process_vertices().

◆ vertex_per_face