ReactOS 0.4.16-dev-340-g0540c21
sprite.c File Reference
#include "d3dx9_private.h"
Include dependency graph for sprite.c:

Go to the source code of this file.

Classes

struct  sprite_vertex
 
struct  sprite
 
struct  d3dx9_sprite
 

Macros

#define D3DXSPRITE_FLAGLIMIT   511
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static struct d3dx9_spriteimpl_from_ID3DXSprite (ID3DXSprite *iface)
 
static HRESULT WINAPI d3dx9_sprite_QueryInterface (ID3DXSprite *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3dx9_sprite_AddRef (ID3DXSprite *iface)
 
static ULONG WINAPI d3dx9_sprite_Release (ID3DXSprite *iface)
 
static HRESULT WINAPI d3dx9_sprite_GetDevice (struct ID3DXSprite *iface, struct IDirect3DDevice9 **device)
 
static HRESULT WINAPI d3dx9_sprite_GetTransform (ID3DXSprite *iface, D3DXMATRIX *transform)
 
static HRESULT WINAPI d3dx9_sprite_SetTransform (ID3DXSprite *iface, const D3DXMATRIX *transform)
 
static HRESULT WINAPI d3dx9_sprite_SetWorldViewRH (ID3DXSprite *iface, const D3DXMATRIX *world, const D3DXMATRIX *view)
 
static HRESULT WINAPI d3dx9_sprite_SetWorldViewLH (ID3DXSprite *iface, const D3DXMATRIX *world, const D3DXMATRIX *view)
 
static void set_states (struct d3dx9_sprite *object)
 
static HRESULT WINAPI d3dx9_sprite_Begin (ID3DXSprite *iface, DWORD flags)
 
static HRESULT WINAPI d3dx9_sprite_Draw (ID3DXSprite *iface, IDirect3DTexture9 *texture, const RECT *rect, const D3DXVECTOR3 *center, const D3DXVECTOR3 *position, D3DCOLOR color)
 
static HRESULT WINAPI d3dx9_sprite_Flush (ID3DXSprite *iface)
 
static HRESULT WINAPI d3dx9_sprite_End (ID3DXSprite *iface)
 
static HRESULT WINAPI d3dx9_sprite_OnLostDevice (ID3DXSprite *iface)
 
static HRESULT WINAPI d3dx9_sprite_OnResetDevice (ID3DXSprite *iface)
 
HRESULT WINAPI D3DXCreateSprite (struct IDirect3DDevice9 *device, struct ID3DXSprite **sprite)
 

Variables

static const ID3DXSpriteVtbl d3dx9_sprite_vtbl
 

Macro Definition Documentation

◆ D3DXSPRITE_FLAGLIMIT

#define D3DXSPRITE_FLAGLIMIT   511

Definition at line 30 of file sprite.c.

Function Documentation

◆ d3dx9_sprite_AddRef()

static ULONG WINAPI d3dx9_sprite_AddRef ( ID3DXSprite *  iface)
static

Definition at line 96 of file sprite.c.

97{
99 ULONG refcount = InterlockedIncrement(&sprite->ref);
100
101 TRACE("%p increasing refcount to %u.\n", sprite, refcount);
102
103 return refcount;
104}
#define InterlockedIncrement
Definition: armddk.h:53
#define TRACE(s)
Definition: solgame.cpp:4
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:73
Definition: sprite.c:40
uint32_t ULONG
Definition: typedefs.h:59

◆ d3dx9_sprite_Begin()

static HRESULT WINAPI d3dx9_sprite_Begin ( ID3DXSprite *  iface,
DWORD  flags 
)
static

Definition at line 281 of file sprite.c.

282{
283 struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
284 HRESULT hr;
285
286 TRACE("iface %p, flags %#x.\n", iface, flags);
287
289
290/* TODO: Implement flags:
291D3DXSPRITE_BILLBOARD: makes the sprite always face the camera
292D3DXSPRITE_DONOTMODIFY_RENDERSTATE: name says it all
293D3DXSPRITE_OBJECTSPACE: do not change device transforms
294D3DXSPRITE_SORT_DEPTH_BACKTOFRONT: sort by position
295D3DXSPRITE_SORT_DEPTH_FRONTTOBACK: sort by position
296D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
297*/
298/* Seems like alpha blending is always enabled, regardless of D3DXSPRITE_ALPHABLEND flag */
302 FIXME("Flags unsupported: %#x\n", flags);
303 /* These flags should only matter to performance */
305 TRACE("Flags unsupported: %#x\n", flags);
306
307 if(This->vdecl==NULL) {
308 static const D3DVERTEXELEMENT9 elements[] =
309 {
314 };
315 IDirect3DDevice9_CreateVertexDeclaration(This->device, elements, &This->vdecl);
316 }
317
319 if(This->stateblock==NULL) {
320 /* Tell our state block what it must store */
322 if(hr!=D3D_OK) return hr;
323
325
327 IDirect3DDevice9_SetStreamSource(This->device, 0, NULL, 0, sizeof(struct sprite_vertex));
330
331 IDirect3DDevice9_EndStateBlock(This->device, &This->stateblock);
332 }
333 IDirect3DStateBlock9_Capture(This->stateblock); /* Save current state */
334 }
335
336 /* Apply device state */
338
339 This->flags=flags;
340 This->ready=TRUE;
341
342 return D3D_OK;
343}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define IDirect3DDevice9_SetIndices(p, a)
Definition: d3d9.h:1611
#define IDirect3DDevice9_CreateVertexDeclaration(p, a, b)
Definition: d3d9.h:1593
#define IDirect3DDevice9_SetStreamSource(p, a, b, c, d)
Definition: d3d9.h:1607
#define IDirect3DDevice9_EndStateBlock(p, a)
Definition: d3d9.h:1568
#define IDirect3DDevice9_BeginStateBlock(p)
Definition: d3d9.h:1567
#define IDirect3DStateBlock9_Capture(p)
Definition: d3d9.h:1303
#define IDirect3DDevice9_SetTexture(p, a, b)
Definition: d3d9.h:1572
#define IDirect3DDevice9_SetVertexDeclaration(p, a)
Definition: d3d9.h:1594
@ D3DDECLUSAGE_TEXCOORD
Definition: d3d9types.h:225
@ D3DDECLUSAGE_POSITION
Definition: d3d9types.h:220
@ D3DDECLUSAGE_COLOR
Definition: d3d9types.h:230
@ D3DDECLTYPE_FLOAT3
Definition: d3d9types.h:257
@ D3DDECLTYPE_D3DCOLOR
Definition: d3d9types.h:259
@ D3DDECLTYPE_FLOAT2
Definition: d3d9types.h:256
#define D3DDECL_END()
Definition: d3d9types.h:311
@ D3DDECLMETHOD_DEFAULT
Definition: d3d9types.h:242
#define D3D_OK
Definition: d3d.h:106
#define D3DERR_INVALIDCALL
#define D3DXSPRITE_DONOTMODIFY_RENDERSTATE
Definition: d3dx9core.h:34
#define D3DXSPRITE_BILLBOARD
Definition: d3dx9core.h:36
#define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT
Definition: d3dx9core.h:40
#define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK
Definition: d3dx9core.h:39
#define D3DXSPRITE_DONOTSAVESTATE
Definition: d3dx9core.h:33
#define D3DXSPRITE_SORT_TEXTURE
Definition: d3dx9core.h:38
#define D3DXSPRITE_OBJECTSPACE
Definition: d3dx9core.h:35
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
GLbitfield flags
Definition: glext.h:7161
HRESULT hr
Definition: shlfolder.c:183
static void set_states(struct d3dx9_sprite *object)
Definition: sprite.c:200
#define D3DXSPRITE_FLAGLIMIT
Definition: sprite.c:30

◆ d3dx9_sprite_Draw()

static HRESULT WINAPI d3dx9_sprite_Draw ( ID3DXSprite *  iface,
IDirect3DTexture9 *  texture,
const RECT rect,
const D3DXVECTOR3 center,
const D3DXVECTOR3 position,
D3DCOLOR  color 
)
static

Definition at line 345 of file sprite.c.

347{
348 struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
349 struct sprite *new_sprites;
350 D3DSURFACE_DESC texdesc;
351
352 TRACE("iface %p, texture %p, rect %s, center %p, position %p, color 0x%08x.\n",
353 iface, texture, wine_dbgstr_rect(rect), center, position, color);
354
355 if(texture==NULL) return D3DERR_INVALIDCALL;
356 if(!This->ready) return D3DERR_INVALIDCALL;
357
358 if (!This->allocated_sprites)
359 {
360 This->sprites = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32 * sizeof(*This->sprites));
361 This->allocated_sprites = 32;
362 }
363 else if (This->allocated_sprites <= This->sprite_count)
364 {
366 This->sprites, This->allocated_sprites * 2 * sizeof(*This->sprites));
367 if (!new_sprites)
368 return E_OUTOFMEMORY;
369 This->sprites = new_sprites;
370 This->allocated_sprites *= 2;
371 }
372 This->sprites[This->sprite_count].texture=texture;
375
376 /* Reuse the texture desc if possible */
377 if(This->sprite_count) {
378 if(This->sprites[This->sprite_count-1].texture!=texture) {
380 } else {
381 texdesc.Width=This->sprites[This->sprite_count-1].texw;
382 texdesc.Height=This->sprites[This->sprite_count-1].texh;
383 }
384 } else IDirect3DTexture9_GetLevelDesc(texture, 0, &texdesc);
385
386 This->sprites[This->sprite_count].texw=texdesc.Width;
387 This->sprites[This->sprite_count].texh=texdesc.Height;
388
389 if (rect)
390 This->sprites[This->sprite_count].rect = *rect;
391 else
392 SetRect(&This->sprites[This->sprite_count].rect, 0, 0, texdesc.Width, texdesc.Height);
393
394 if(center==NULL) {
395 This->sprites[This->sprite_count].center.x=0.0f;
396 This->sprites[This->sprite_count].center.y=0.0f;
397 This->sprites[This->sprite_count].center.z=0.0f;
398 } else This->sprites[This->sprite_count].center=*center;
399
400 if(position==NULL) {
401 This->sprites[This->sprite_count].pos.x=0.0f;
402 This->sprites[This->sprite_count].pos.y=0.0f;
403 This->sprites[This->sprite_count].pos.z=0.0f;
404 } else This->sprites[This->sprite_count].pos=*position;
405
406 This->sprites[This->sprite_count].color=color;
407 This->sprites[This->sprite_count].transform=This->transform;
408 This->sprite_count++;
409
410 return D3D_OK;
411}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
#define IDirect3DTexture9_AddRef(p)
Definition: d3d9.h:1013
#define D3DXSPRITE_DO_NOT_ADDREF_TEXTURE
Definition: d3dx9core.h:41
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLenum GLuint texture
Definition: glext.h:6295
GLuint color
Definition: glext.h:6243
& rect
Definition: startmenu.cpp:1413
D3DXVECTOR3 center
Definition: sprite.c:44
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

◆ d3dx9_sprite_End()

static HRESULT WINAPI d3dx9_sprite_End ( ID3DXSprite *  iface)
static

Definition at line 487 of file sprite.c.

488{
490
491 TRACE("iface %p.\n", iface);
492
493 if (!sprite->ready)
494 return D3DERR_INVALIDCALL;
495
496 ID3DXSprite_Flush(iface);
497
498 if (sprite->stateblock && !(sprite->flags & D3DXSPRITE_DONOTSAVESTATE))
499 IDirect3DStateBlock9_Apply(sprite->stateblock); /* Restore old state */
500
501 sprite->ready = FALSE;
502
503 return D3D_OK;
504}
#define IDirect3DStateBlock9_Apply(p)
Definition: d3d9.h:1304
#define ID3DXSprite_Flush(p)
Definition: d3dx9core.h:451
#define FALSE
Definition: types.h:117

◆ d3dx9_sprite_Flush()

static HRESULT WINAPI d3dx9_sprite_Flush ( ID3DXSprite *  iface)
static

Definition at line 413 of file sprite.c.

414{
415 struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
416 struct sprite_vertex *vertices;
417 int i, count=0, start;
418
419 TRACE("iface %p.\n", iface);
420
421 if(!This->ready) return D3DERR_INVALIDCALL;
422 if(!This->sprite_count) return D3D_OK;
423
424/* TODO: use of a vertex buffer here */
425 vertices = HeapAlloc(GetProcessHeap(), 0, sizeof(*vertices) * 6 * This->sprite_count);
426
427 for(start=0;start<This->sprite_count;start+=count,count=0) {
428 i=start;
429 while(i<This->sprite_count &&
430 (count==0 || This->sprites[i].texture==This->sprites[i-1].texture)) {
431 float spritewidth=(float)This->sprites[i].rect.right-(float)This->sprites[i].rect.left;
432 float spriteheight=(float)This->sprites[i].rect.bottom-(float)This->sprites[i].rect.top;
433
434 vertices[6*i ].pos.x = This->sprites[i].pos.x - This->sprites[i].center.x;
435 vertices[6*i ].pos.y = This->sprites[i].pos.y - This->sprites[i].center.y;
436 vertices[6*i ].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
437 vertices[6*i+1].pos.x = spritewidth + This->sprites[i].pos.x - This->sprites[i].center.x;
438 vertices[6*i+1].pos.y = This->sprites[i].pos.y - This->sprites[i].center.y;
439 vertices[6*i+1].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
440 vertices[6*i+2].pos.x = spritewidth + This->sprites[i].pos.x - This->sprites[i].center.x;
441 vertices[6*i+2].pos.y = spriteheight + This->sprites[i].pos.y - This->sprites[i].center.y;
442 vertices[6*i+2].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
443 vertices[6*i+3].pos.x = This->sprites[i].pos.x - This->sprites[i].center.x;
444 vertices[6*i+3].pos.y = spriteheight + This->sprites[i].pos.y - This->sprites[i].center.y;
445 vertices[6*i+3].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
446 vertices[6*i ].col = This->sprites[i].color;
447 vertices[6*i+1].col = This->sprites[i].color;
448 vertices[6*i+2].col = This->sprites[i].color;
449 vertices[6*i+3].col = This->sprites[i].color;
450 vertices[6*i ].tex.x = (float)This->sprites[i].rect.left / (float)This->sprites[i].texw;
451 vertices[6*i ].tex.y = (float)This->sprites[i].rect.top / (float)This->sprites[i].texh;
452 vertices[6*i+1].tex.x = (float)This->sprites[i].rect.right / (float)This->sprites[i].texw;
453 vertices[6*i+1].tex.y = (float)This->sprites[i].rect.top / (float)This->sprites[i].texh;
454 vertices[6*i+2].tex.x = (float)This->sprites[i].rect.right / (float)This->sprites[i].texw;
455 vertices[6*i+2].tex.y = (float)This->sprites[i].rect.bottom / (float)This->sprites[i].texh;
456 vertices[6*i+3].tex.x = (float)This->sprites[i].rect.left / (float)This->sprites[i].texw;
457 vertices[6*i+3].tex.y = (float)This->sprites[i].rect.bottom / (float)This->sprites[i].texh;
458
459 vertices[6*i+4]=vertices[6*i];
460 vertices[6*i+5]=vertices[6*i+2];
461
462 D3DXVec3TransformCoordArray(&vertices[6 * i].pos, sizeof(*vertices),
463 &vertices[6 * i].pos, sizeof(*vertices), &This->sprites[i].transform, 6);
464 count++;
465 i++;
466 }
467
468 IDirect3DDevice9_SetTexture(This->device, 0, (struct IDirect3DBaseTexture9 *)This->sprites[start].texture);
470
472 2 * count, vertices + 6 * start, sizeof(*vertices));
473 }
474 HeapFree(GetProcessHeap(), 0, vertices);
475
477 for(i=0;i<This->sprite_count;i++)
478 IDirect3DTexture9_Release(This->sprites[i].texture);
479
480 This->sprite_count=0;
481
482 /* Flush may be called more than once, so we don't reset This->ready here */
483
484 return D3D_OK;
485}
@ D3DPT_TRIANGLELIST
Definition: d3d8types.h:721
#define IDirect3DDevice9_DrawPrimitiveUP(p, a, b, c, d)
Definition: d3d9.h:1590
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
D3DXVECTOR3 *WINAPI D3DXVec3TransformCoordArray(D3DXVECTOR3 *out, UINT outstride, const D3DXVECTOR3 *in, UINT instride, const D3DXMATRIX *matrix, UINT elements)
Definition: math.c:1913
#define HeapFree(x, y, z)
Definition: compat.h:735
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
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 GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static float(__cdecl *square_half_float)(float x
FLOAT x
Definition: d3dx9math.h:64
FLOAT y
Definition: d3dx9math.h:64
DWORD col
Definition: sprite.c:35
D3DXVECTOR3 pos
Definition: sprite.c:34
D3DXVECTOR2 tex
Definition: sprite.c:36

◆ d3dx9_sprite_GetDevice()

static HRESULT WINAPI d3dx9_sprite_GetDevice ( struct ID3DXSprite *  iface,
struct IDirect3DDevice9 **  device 
)
static

Definition at line 143 of file sprite.c.

144{
146
147 TRACE("iface %p, device %p.\n", iface, device);
148
149 if (!device)
150 return D3DERR_INVALIDCALL;
151 *device = sprite->device;
153
154 return D3D_OK;
155}
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
Definition: devices.h:37

◆ d3dx9_sprite_GetTransform()

static HRESULT WINAPI d3dx9_sprite_GetTransform ( ID3DXSprite *  iface,
D3DXMATRIX transform 
)
static

Definition at line 157 of file sprite.c.

158{
160
161 TRACE("iface %p, transform %p.\n", iface, transform);
162
163 if (!transform)
164 return D3DERR_INVALIDCALL;
166
167 return D3D_OK;
168}
GLuint GLenum GLenum transform
Definition: glext.h:9407
D3DXMATRIX transform
Definition: sprite.c:47

◆ d3dx9_sprite_OnLostDevice()

static HRESULT WINAPI d3dx9_sprite_OnLostDevice ( ID3DXSprite *  iface)
static

Definition at line 506 of file sprite.c.

507{
509
510 TRACE("iface %p.\n", iface);
511
512 if (sprite->stateblock)
514 if (sprite->vdecl)
516 sprite->vdecl = NULL;
517 sprite->stateblock = NULL;
518
519 /* Reset some variables */
521
522 return D3D_OK;
523}
#define IDirect3DStateBlock9_Release(p)
Definition: d3d9.h:1300
#define IDirect3DVertexDeclaration9_Release(p)
Definition: d3d9.h:1185
#define ID3DXSprite_OnResetDevice(p)
Definition: d3dx9core.h:454

◆ d3dx9_sprite_OnResetDevice()

static HRESULT WINAPI d3dx9_sprite_OnResetDevice ( ID3DXSprite *  iface)
static

Definition at line 525 of file sprite.c.

526{
528 int i;
529
530 TRACE("iface %p.\n", iface);
531
533 {
534 for (i = 0; i < sprite->sprite_count; ++i)
535 {
536 if (sprite->sprites[i].texture)
538 }
539 }
540
541 sprite->sprite_count = 0;
542 sprite->flags = 0;
543 sprite->ready = FALSE;
544
545 /* keep matrices */
546 /* device objects get restored on Begin */
547
548 return D3D_OK;
549}
IDirect3DTexture9 * texture
Definition: sprite.c:41

◆ d3dx9_sprite_QueryInterface()

static HRESULT WINAPI d3dx9_sprite_QueryInterface ( ID3DXSprite *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 78 of file sprite.c.

79{
80 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
81
82 if (IsEqualGUID(riid, &IID_ID3DXSprite)
84 {
85 IUnknown_AddRef(iface);
86 *out = iface;
87 return S_OK;
88 }
89
90 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
91
92 *out = NULL;
93 return E_NOINTERFACE;
94}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static FILE * out
Definition: regtests2xml.c:44
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ d3dx9_sprite_Release()

static ULONG WINAPI d3dx9_sprite_Release ( ID3DXSprite *  iface)
static

Definition at line 106 of file sprite.c.

107{
109 ULONG refcount = InterlockedDecrement(&sprite->ref);
110
111 TRACE("%p decreasing refcount to %u.\n", sprite, refcount);
112
113 if (!refcount)
114 {
115 if (sprite->sprites)
116 {
117 int i;
118
120 {
121 for (i = 0; i < sprite->sprite_count; ++i)
122 {
123 if (sprite->sprites[i].texture)
125 }
126 }
127
128 HeapFree(GetProcessHeap(), 0, sprite->sprites);
129 }
130
131 if (sprite->stateblock)
133 if (sprite->vdecl)
135 if (sprite->device)
138 }
139
140 return refcount;
141}
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508

◆ d3dx9_sprite_SetTransform()

static HRESULT WINAPI d3dx9_sprite_SetTransform ( ID3DXSprite *  iface,
const D3DXMATRIX transform 
)
static

Definition at line 170 of file sprite.c.

171{
173
174 TRACE("iface %p, transform %p.\n", iface, transform);
175
176 if (!transform)
177 return D3DERR_INVALIDCALL;
179
180 return D3D_OK;
181}

◆ d3dx9_sprite_SetWorldViewLH()

static HRESULT WINAPI d3dx9_sprite_SetWorldViewLH ( ID3DXSprite *  iface,
const D3DXMATRIX world,
const D3DXMATRIX view 
)
static

Definition at line 191 of file sprite.c.

193{
194 FIXME("iface %p, world %p, view %p stub!\n", iface, world, view);
195
196 return E_NOTIMPL;
197}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_sprite_SetWorldViewRH()

static HRESULT WINAPI d3dx9_sprite_SetWorldViewRH ( ID3DXSprite *  iface,
const D3DXMATRIX world,
const D3DXMATRIX view 
)
static

Definition at line 183 of file sprite.c.

185{
186 FIXME("iface %p, world %p, view %p stub!\n", iface, world, view);
187
188 return E_NOTIMPL;
189}

◆ D3DXCreateSprite()

HRESULT WINAPI D3DXCreateSprite ( struct IDirect3DDevice9 *  device,
struct ID3DXSprite **  sprite 
)

Definition at line 569 of file sprite.c.

570{
571 struct d3dx9_sprite *object;
572 D3DCAPS9 caps;
573
574 TRACE("device %p, sprite %p.\n", device, sprite);
575
576 if(device==NULL || sprite==NULL) return D3DERR_INVALIDCALL;
577
578 if (!(object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
579 {
580 *sprite = NULL;
581 return E_OUTOFMEMORY;
582 }
583 object->ID3DXSprite_iface.lpVtbl = &d3dx9_sprite_vtbl;
584 object->ref=1;
585 object->device=device;
586 IUnknown_AddRef(device);
587
588 object->vdecl=NULL;
589 object->stateblock=NULL;
590
591 D3DXMatrixIdentity(&object->transform);
592 D3DXMatrixIdentity(&object->view);
593
595 object->texfilter_caps=caps.TextureFilterCaps;
596 object->maxanisotropy=caps.MaxAnisotropy;
597 object->alphacmp_caps=caps.AlphaCmpCaps;
598
599 ID3DXSprite_OnResetDevice(&object->ID3DXSprite_iface);
600
601 object->sprites=NULL;
602 object->allocated_sprites=0;
603 *sprite=&object->ID3DXSprite_iface;
604
605 return D3D_OK;
606}
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
static const ID3DXSpriteVtbl d3dx9_sprite_vtbl
Definition: sprite.c:551
DWORD TextureFilterCaps
Definition: d3d9caps.h:280
DWORD MaxAnisotropy
Definition: d3d9caps.h:291
DWORD AlphaCmpCaps
Definition: d3d9caps.h:277
IDirect3DDevice9 * device
Definition: sprite.c:55

Referenced by ID3DXFontImpl_DrawTextW(), test_ID3DXFont(), and test_ID3DXSprite().

◆ impl_from_ID3DXSprite()

static struct d3dx9_sprite * impl_from_ID3DXSprite ( ID3DXSprite *  iface)
inlinestatic

◆ set_states()

static void set_states ( struct d3dx9_sprite object)
static

Definition at line 200 of file sprite.c.

201{
203 D3DVIEWPORT9 vp;
204
205 /* Miscellaneous stuff */
209
210 /* Render states */
237
238 /* Texture stage states */
249
250 /* Sampler states */
253
254 if(object->texfilter_caps & D3DPTFILTERCAPS_MAGFANISOTROPIC)
257
260
261 if(object->texfilter_caps & D3DPTFILTERCAPS_MINFANISOTROPIC)
264
265 if(object->texfilter_caps & D3DPTFILTERCAPS_MIPFLINEAR)
268
271
272 /* Matrices */
273 D3DXMatrixIdentity(&mat);
277 D3DXMatrixOrthoOffCenterLH(&mat, vp.X+0.5f, (float)vp.Width+vp.X+0.5f, (float)vp.Height+vp.Y+0.5f, vp.Y+0.5f, vp.MinZ, vp.MaxZ);
279}
#define D3DPTFILTERCAPS_MIPFLINEAR
Definition: d3d8caps.h:132
#define D3DPTFILTERCAPS_MINFANISOTROPIC
Definition: d3d8caps.h:130
#define D3DPTFILTERCAPS_MAGFANISOTROPIC
Definition: d3d8caps.h:135
@ D3DRS_VERTEXBLEND
Definition: d3d8types.h:783
@ D3DRS_SHADEMODE
Definition: d3d8types.h:731
@ D3DRS_STENCILENABLE
Definition: d3d8types.h:755
@ D3DRS_WRAP0
Definition: d3d8types.h:764
@ D3DRS_CULLMODE
Definition: d3d8types.h:738
@ D3DRS_ALPHATESTENABLE
Definition: d3d8types.h:734
@ D3DRS_SRCBLEND
Definition: d3d8types.h:736
@ D3DRS_CLIPPLANEENABLE
Definition: d3d8types.h:784
@ D3DRS_ALPHAFUNC
Definition: d3d8types.h:741
@ D3DRS_DESTBLEND
Definition: d3d8types.h:737
@ D3DRS_FILLMODE
Definition: d3d8types.h:730
@ D3DRS_CLIPPING
Definition: d3d8types.h:772
@ D3DRS_BLENDOP
Definition: d3d8types.h:802
@ D3DRS_ALPHABLENDENABLE
Definition: d3d8types.h:743
@ D3DRS_COLORWRITEENABLE
Definition: d3d8types.h:800
@ D3DRS_SPECULARENABLE
Definition: d3d8types.h:745
@ D3DRS_ALPHAREF
Definition: d3d8types.h:740
@ D3DRS_DIFFUSEMATERIALSOURCE
Definition: d3d8types.h:779
@ D3DRS_INDEXEDVERTEXBLENDENABLE
Definition: d3d8types.h:799
@ D3DRS_LIGHTING
Definition: d3d8types.h:773
@ D3DRS_RANGEFOGENABLE
Definition: d3d8types.h:754
@ D3DRS_FOGENABLE
Definition: d3d8types.h:744
#define D3DCOLORWRITEENABLE_ALPHA
Definition: d3d8types.h:151
@ D3DSHADE_GOURAUD
Definition: d3d8types.h:823
@ D3DTADDRESS_CLAMP
Definition: d3d8types.h:862
@ D3DTTFF_DISABLE
Definition: d3d8types.h:944
#define D3DCOLORWRITEENABLE_RED
Definition: d3d8types.h:148
@ D3DBLEND_SRCALPHA
Definition: d3d8types.h:513
@ D3DBLEND_INVSRCALPHA
Definition: d3d8types.h:514
@ D3DTEXF_POINT
Definition: d3d8types.h:871
@ D3DTEXF_ANISOTROPIC
Definition: d3d8types.h:873
@ D3DTEXF_LINEAR
Definition: d3d8types.h:872
@ D3DTSS_ALPHAARG2
Definition: d3d8types.h:917
@ D3DTSS_COLOROP
Definition: d3d8types.h:912
@ D3DTSS_TEXCOORDINDEX
Definition: d3d8types.h:922
@ D3DTSS_ALPHAOP
Definition: d3d8types.h:915
@ D3DTSS_COLORARG1
Definition: d3d8types.h:913
@ D3DTSS_TEXTURETRANSFORMFLAGS
Definition: d3d8types.h:934
@ D3DTSS_ALPHAARG1
Definition: d3d8types.h:916
@ D3DTSS_COLORARG2
Definition: d3d8types.h:914
@ D3DTOP_MODULATE
Definition: d3d8types.h:884
@ D3DTOP_DISABLE
Definition: d3d8types.h:881
#define D3DCOLORWRITEENABLE_GREEN
Definition: d3d8types.h:149
@ D3DMCS_COLOR1
Definition: d3d8types.h:665
@ D3DBLENDOP_ADD
Definition: d3d8types.h:527
#define D3DTA_DIFFUSE
Definition: d3d8types.h:139
#define D3DTA_TEXTURE
Definition: d3d8types.h:141
@ D3DCULL_NONE
Definition: d3d8types.h:561
@ D3DCMP_GREATER
Definition: d3d8types.h:541
#define D3DCOLORWRITEENABLE_BLUE
Definition: d3d8types.h:150
@ D3DTS_VIEW
Definition: d3d8types.h:955
@ D3DTS_PROJECTION
Definition: d3d8types.h:956
#define D3DTS_WORLD
Definition: d3d8types.h:85
@ D3DFILL_SOLID
Definition: d3d8types.h:586
#define IDirect3DDevice9_SetTextureStageState(p, a, b, c)
Definition: d3d9.h:1574
#define IDirect3DDevice9_SetNPatchMode(p, a)
Definition: d3d9.h:1586
#define IDirect3DDevice9_SetRenderState(p, a, b)
Definition: d3d9.h:1564
#define IDirect3DDevice9_SetPixelShader(p, a)
Definition: d3d9.h:1614
#define IDirect3DDevice9_GetViewport(p, a)
Definition: d3d9.h:1555
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1551
#define IDirect3DDevice9_SetVertexShader(p, a)
Definition: d3d9.h:1599
#define IDirect3DDevice9_SetSamplerState(p, a, b, c)
Definition: d3d9.h:1576
@ D3DRS_ENABLEADAPTIVETESSELLATION
Definition: d3d9types.h:999
@ D3DRS_SEPARATEALPHABLENDENABLE
Definition: d3d9types.h:1019
@ D3DRS_SRGBWRITEENABLE
Definition: d3d9types.h:1009
@ D3DSAMP_MIPFILTER
Definition: d3d9types.h:1205
@ D3DSAMP_MAXMIPLEVEL
Definition: d3d9types.h:1207
@ D3DSAMP_SRGBTEXTURE
Definition: d3d9types.h:1209
@ D3DSAMP_MAXANISOTROPY
Definition: d3d9types.h:1208
@ D3DSAMP_MINFILTER
Definition: d3d9types.h:1204
@ D3DSAMP_ADDRESSU
Definition: d3d9types.h:1199
@ D3DSAMP_MAGFILTER
Definition: d3d9types.h:1203
@ D3DSAMP_ADDRESSV
Definition: d3d9types.h:1200
@ D3DSAMP_MIPMAPLODBIAS
Definition: d3d9types.h:1206
D3DXMATRIX *WINAPI D3DXMatrixOrthoOffCenterLH(D3DXMATRIX *pout, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf)
Definition: math.c:443
static const MAT2 mat
Definition: font.c:66

Referenced by d3dx9_sprite_Begin().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

Variable Documentation

◆ d3dx9_sprite_vtbl

const ID3DXSpriteVtbl d3dx9_sprite_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3dx9_sprite_SetTransform(ID3DXSprite *iface, const D3DXMATRIX *transform)
Definition: sprite.c:170
static HRESULT WINAPI d3dx9_sprite_GetTransform(ID3DXSprite *iface, D3DXMATRIX *transform)
Definition: sprite.c:157
static HRESULT WINAPI d3dx9_sprite_QueryInterface(ID3DXSprite *iface, REFIID riid, void **out)
Definition: sprite.c:78
static HRESULT WINAPI d3dx9_sprite_SetWorldViewLH(ID3DXSprite *iface, const D3DXMATRIX *world, const D3DXMATRIX *view)
Definition: sprite.c:191
static HRESULT WINAPI d3dx9_sprite_OnLostDevice(ID3DXSprite *iface)
Definition: sprite.c:506
static HRESULT WINAPI d3dx9_sprite_GetDevice(struct ID3DXSprite *iface, struct IDirect3DDevice9 **device)
Definition: sprite.c:143
static HRESULT WINAPI d3dx9_sprite_End(ID3DXSprite *iface)
Definition: sprite.c:487
static HRESULT WINAPI d3dx9_sprite_Flush(ID3DXSprite *iface)
Definition: sprite.c:413
static HRESULT WINAPI d3dx9_sprite_SetWorldViewRH(ID3DXSprite *iface, const D3DXMATRIX *world, const D3DXMATRIX *view)
Definition: sprite.c:183
static HRESULT WINAPI d3dx9_sprite_Begin(ID3DXSprite *iface, DWORD flags)
Definition: sprite.c:281
static ULONG WINAPI d3dx9_sprite_AddRef(ID3DXSprite *iface)
Definition: sprite.c:96
static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *texture, const RECT *rect, const D3DXVECTOR3 *center, const D3DXVECTOR3 *position, D3DCOLOR color)
Definition: sprite.c:345
static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
Definition: sprite.c:106
static HRESULT WINAPI d3dx9_sprite_OnResetDevice(ID3DXSprite *iface)
Definition: sprite.c:525

Definition at line 551 of file sprite.c.

Referenced by D3DXCreateSprite().