Am Sonntag 06 August 2006 13:05 schrieb H. Verbeet: > On 06/08/06, Stefan Dösinger <[EMAIL PROTECTED]> wrote: > > Am Sonntag 06 August 2006 12:12 schrieb H. Verbeet: > > > On 06/08/06, Stefan Dösinger <[EMAIL PROTECTED]> wrote: > > > > If the cursor is not 32x32 pixels then disable the gdi cursor, > > > > > > Are you sure that's required? > > > > We might end up with 2 active cursors, the one drawn with the Blit and > > the gdi cursor. > > Well yes, but the Remarks section for IDirect3DDevice9::ShowCursor() > seems to suggest that is what is supposed to happen. Due to the lack of games to test with I have written a small test app do draw the cursor. I tested it on win2k with a geforce 2 card.
With a 32x32 cursor SetCursor set the gdi cursor image to my d3d cursor, and placed the cursor position. If I moved the mouse the cursor moved. The old cusor(hourglass) disappeared With a 64x64 the d3d cursor was drawn at the requested position, but didn't move when I moved the mouse. The hourglass wasn't shown. My cursor tests are in the attached file. Our GetFrontBufferData implementation needs some more work for the automated tests to work(Well, I think a call to IWineD3DSurface::BltFast should do the job).
/* * Copyright (C) 2005 Henri Verbeet * Copyright (C) 2006 Stefan Dösinger(for CodeWeavers) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #define COBJMACROS #include <d3d9.h> #include "wine/test.h" static HMODULE d3d9_handle = 0; static HWND create_window(void) { WNDCLASS wc = {0}; wc.lpfnWndProc = &DefWindowProc; wc.lpszClassName = "d3d9_test_wc"; RegisterClass(&wc); return CreateWindow("d3d9_test_wc", "d3d9_test", 0, 0, 0, 0, 0, 0, 0, 0, 0); } static DWORD getPixelColor(IDirect3DDevice9 *device, UINT x, UINT y) { DWORD ret; IDirect3DSurface9 *surf; HRESULT hr; D3DLOCKED_RECT lockedRect; RECT rectToLock = {x, y, 1, 1}; hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 640, 480, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf, NULL); if(FAILED(hr) || !surf ) /* This is not a test */ { trace("Can't create an offscreen plain surface to read the front buffer data, hr=%08lx\n", hr); return 0xdeadbeef; } hr = IDirect3DDevice9_GetFrontBufferData(device, 0, surf); if(FAILED(hr)) { trace("Can't read the front buffer data, hr=%08lx\n", hr); ret = 0xdeadbeee; goto out; } hr = IDirect3DSurface9_LockRect(surf, &lockedRect, &rectToLock, D3DLOCK_READONLY); if(FAILED(hr)) { trace("Can't lock the offscreen surface, hr=%08lx\n", hr); ret = 0xdeadbeed; goto out; } ret = ((DWORD *) lockedRect.pBits)[0]; hr = IDirect3DSurface9_UnlockRect(surf); if(FAILED(hr)) { trace("Can't unlock the offscreen surface, hr=%08lx\n", hr); } out: IDirect3DSurface9_Release(surf); return ret; } static IDirect3DDevice9 *init_d3d9(void) { IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0; IDirect3D9 *d3d9_ptr = 0; IDirect3DDevice9 *device_ptr = 0; D3DPRESENT_PARAMETERS present_parameters; HRESULT hr; d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9"); ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n"); if (!d3d9_create) return NULL; d3d9_ptr = d3d9_create(D3D_SDK_VERSION); ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n"); if (!d3d9_ptr) return NULL; ZeroMemory(&present_parameters, sizeof(present_parameters)); present_parameters.Windowed = FALSE; present_parameters.hDeviceWindow = create_window(); present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; present_parameters.BackBufferWidth = 640; present_parameters.BackBufferHeight = 480; present_parameters.BackBufferFormat = D3DFMT_X8R8G8B8; hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr); ok(hr == D3D_OK, "IDirect3D_CreateDevice returned: 0x%lx\n", hr); return device_ptr; } struct SNVERTEX { float x, y, z; D3DVECTOR normale; DWORD specular; }; static void test_vertexdata(IDirect3DDevice9 *device) { HRESULT hr; static struct SNVERTEX quad[] = { {-1.0, -1.0, 0.1, {0.0, 0.0, -1.0}, 0xffffff00}, {-1.0, 1.0, 0.1, {0.0, 0.0, -1.0}, 0xffffff00}, { 1.0, 1.0, 0.1, {0.0, 0.0, -1.0}, 0xffffff00}, { 1.0, 1.0, 0.1, {0.0, 0.0, -1.0}, 0xffffff00}, { 1.0, -1.0, 0.1, {0.0, 0.0, -1.0}, 0xffffff00}, {-1.0, -1.0, 0.1, {0.0, 0.0, -1.0}, 0xffffff00}, }; const D3DLIGHT9 light = { D3DLIGHT_DIRECTIONAL, /* Type */ { 1.0, 1.0, 1.0, 1.0 }, /* Diffuse r,g,b,a */ { 1.0, 1.0, 1.0, 1.0 }, /* Specular r,g,b,a */ { 1.0, 1.0, 1.0, 1.0 }, /* Ambient r,g,b,a, */ { 0.0, 0.0, 0.0 }, /* Position x,y,z */ { 0.0, 0.0, 1.0 }, /* Direction x,y,z */ 5.0, /* Range */ 0.0, /* Falloff */ 0.0, 0.0, 0.0, /* Attenuation 0,1,2 */ 0.0, /* Theta */ 0.0 /* Phi */ }; hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState(D3DRS_ZENABLE, FALSE) failed with %08lx\n", hr); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) failed with %08lx\n", hr); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARENABLE, TRUE); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState(D3DRS_SPECULARENABLE, TRUE) failed with %08lx\n", hr); hr = IDirect3DDevice9_SetLight(device, 0, &light); ok(hr == D3D_OK, "IDirect3DDevice9_SetLight returned %08lx\n", hr); hr = IDirect3DDevice9_LightEnable(device, 0, TRUE); ok(hr == D3D_OK, "IDirect3DDevice9_LightEnable returned %08lx\n", hr); hr =IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_SPECULAR | D3DFVF_NORMAL); ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF(D3DFVF_XYZRHW | D3DFVF_SPECULAR) failed with %08lx\n", hr); IDirect3DDevice9_BeginScene(device); ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene() failed with %08lx\n", hr); hr =IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 1, &quad[0], sizeof(struct SNVERTEX)); ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, %p, %d) failed with %08lx\n", quad, sizeof(struct SNVERTEX), hr); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARENABLE, FALSE); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState(D3DRS_SPECULARENABLE, TRUE) failed with %08lx\n", hr); hr =IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 1, &quad[3], sizeof(struct SNVERTEX)); ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, %p, %d) failed with %08lx\n", quad, sizeof(struct SNVERTEX), hr); IDirect3DDevice9_EndScene(device); ok(hr == D3D_OK, "IDirect3DDevice9_EndScene() failed with %08lx\n", hr); hr =IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(hr == D3D_OK, "IDirect3DDevice9_Present(NULL, NULL, NULL, NULL) failed with %08lx\n", hr); Sleep(3000); } static void test_cursor(IDirect3DDevice9 *device) { HRESULT hr; RECT rect = { 8, 8, 24, 24}; RECT rect2 = { 40, 40, 56, 56}; IDirect3DSurface9 *cursor = NULL; ULONG ref; hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0); ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08lx\n", hr); IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &cursor, 0); ok(cursor != NULL, "IDirect3DDevice9_CreateOffscreenPlainSurface failed with %08lx\n", hr); hr = IDirect3DDevice9_ColorFill(device, cursor, NULL, 0xffffff00); ok(hr == D3D_OK, "IDirect3DDevice9_ColorFill failed with %08lx\n", hr); hr = IDirect3DDevice9_ColorFill(device, cursor, &rect, 0x00ff0000); ok(hr == D3D_OK, "IDirect3DDevice9_ColorFill failed with %08lx\n", hr); hr = IDirect3DDevice9_ColorFill(device, cursor, &rect2, 0xff0000ff); ok(hr == D3D_OK, "IDirect3DDevice9_ColorFill failed with %08lx\n", hr); IDirect3DSurface9_AddRef(cursor); ref = IDirect3DSurface9_Release(cursor); ok(ref == 1, "Bloody murder\n"); hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor); ok(hr == D3D_OK, "IDirect3DDevice9_SetCursorProperties failed with %08lx\n", hr); IDirect3DSurface9_AddRef(cursor); ref = IDirect3DSurface9_Release(cursor); ok(ref == 1, "Cursor reference count is %lx\n", ref); ref = IDirect3DSurface9_Release(cursor); IDirect3DDevice9_SetCursorPosition(device, 100, 100, 0); IDirect3DDevice9_ShowCursor(device, TRUE); hr =IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(hr == D3D_OK, "IDirect3DDevice9_Present(NULL, NULL, NULL, NULL) failed with %08lx\n", hr); Sleep(3000); } START_TEST(visual) { IDirect3DDevice9 *device_ptr; HRESULT hr; DWORD color; d3d9_handle = LoadLibraryA("d3d9.dll"); if (!d3d9_handle) { trace("Could not load d3d9.dll, skipping tests\n"); return; } device_ptr = init_d3d9(); if (!device_ptr) return; #if 0 /* Check for the reliability of the returned data */ hr = IDirect3DDevice9_Clear(device_ptr, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); if(FAILED(hr)) { trace("Clear failed, can't assure correctness of the test results, skipping\n"); return; } IDirect3DDevice9_Present(device_ptr, NULL, NULL, NULL, NULL); color = getPixelColor(device_ptr, 0, 0); if(color !=0x00ff0000) { trace("Sanity check returned an incorrect color(%08lx), can't assure the correctness of the tests, skipping\n", color); return; } hr = IDirect3DDevice9_Clear(device_ptr, 0, NULL, D3DCLEAR_TARGET, 0xff00ddee, 0.0, 0); if(FAILED(hr)) { trace("Clear failed, can't assure correctness of the test results, skipping\n"); return; } IDirect3DDevice9_Present(device_ptr, NULL, NULL, NULL, NULL); color = getPixelColor(device_ptr, 639, 479); if(color != 0x0000ddee) { trace("Sanity check returned an incorrect color(%08lx), can't assure the correctness of the tests, skipping\n", color); return; } #endif test_vertexdata(device_ptr); test_cursor(device_ptr); }
pgp7mOm5UZOWw.pgp
Description: PGP signature