ReactOS  0.4.14-dev-323-g6fe6a88
sprite.c File Reference
#include "config.h"
#include "wine/port.h"
#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 28 of file sprite.c.

Function Documentation

◆ d3dx9_sprite_AddRef()

static ULONG WINAPI d3dx9_sprite_AddRef ( ID3DXSprite *  iface)
static

Definition at line 94 of file sprite.c.

95 {
96  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
97  ULONG refcount = InterlockedIncrement(&sprite->ref);
98 
99  TRACE("%p increasing refcount to %u.\n", sprite, refcount);
100 
101  return refcount;
102 }
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
#define TRACE(s)
Definition: solgame.cpp:4
Definition: sprite.c:37
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ d3dx9_sprite_Begin()

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

Definition at line 276 of file sprite.c.

277 {
278  struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
279  HRESULT hr;
280 
281  TRACE("iface %p, flags %#x.\n", iface, flags);
282 
283  if(flags>D3DXSPRITE_FLAGLIMIT || This->ready) return D3DERR_INVALIDCALL;
284 
285 /* TODO: Implement flags:
286 D3DXSPRITE_BILLBOARD: makes the sprite always face the camera
287 D3DXSPRITE_DONOTMODIFY_RENDERSTATE: name says it all
288 D3DXSPRITE_OBJECTSPACE: do not change device transforms
289 D3DXSPRITE_SORT_DEPTH_BACKTOFRONT: sort by position
290 D3DXSPRITE_SORT_DEPTH_FRONTTOBACK: sort by position
291 D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
292 */
293 /* Seems like alpha blending is always enabled, regardless of D3DXSPRITE_ALPHABLEND flag */
297  FIXME("Flags unsupported: %#x\n", flags);
298  /* These flags should only matter to performance */
300  TRACE("Flags unsupported: %#x\n", flags);
301 
302  if(This->vdecl==NULL) {
303  static const D3DVERTEXELEMENT9 elements[] =
304  {
308  D3DDECL_END()
309  };
310  IDirect3DDevice9_CreateVertexDeclaration(This->device, elements, &This->vdecl);
311  }
312 
314  if(This->stateblock==NULL) {
315  /* Tell our state block what it must store */
317  if(hr!=D3D_OK) return hr;
318 
319  set_states(This);
320 
322  IDirect3DDevice9_SetStreamSource(This->device, 0, NULL, 0, sizeof(struct sprite_vertex));
325 
326  IDirect3DDevice9_EndStateBlock(This->device, &This->stateblock);
327  }
328  IDirect3DStateBlock9_Capture(This->stateblock); /* Save current state */
329  }
330 
331  /* Apply device state */
332  set_states(This);
333 
334  This->flags=flags;
335  This->ready=TRUE;
336 
337  return D3D_OK;
338 }
#define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT
Definition: d3dx9core.h:40
#define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK
Definition: d3dx9core.h:39
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
#define IDirect3DDevice9_CreateVertexDeclaration(p, a, b)
Definition: d3d9.h:1593
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
#define D3DXSPRITE_DONOTSAVESTATE
Definition: d3dx9core.h:33
#define D3DXSPRITE_BILLBOARD
Definition: d3dx9core.h:36
#define FIXME(fmt,...)
Definition: debug.h:110
#define IDirect3DDevice9_SetStreamSource(p, a, b, c, d)
Definition: d3d9.h:1607
#define D3DXSPRITE_SORT_TEXTURE
Definition: d3dx9core.h:38
smooth NULL
Definition: ftsmooth.c:416
#define IDirect3DDevice9_BeginStateBlock(p)
Definition: d3d9.h:1567
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define IDirect3DStateBlock9_Capture(p)
Definition: d3d9.h:1303
GLbitfield flags
Definition: glext.h:7161
#define D3DDECL_END()
Definition: d3d9types.h:311
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_SetTexture(p, a, b)
Definition: d3d9.h:1572
#define IDirect3DDevice9_SetIndices(p, a)
Definition: d3d9.h:1611
#define D3DXSPRITE_DONOTMODIFY_RENDERSTATE
Definition: d3dx9core.h:34
static void set_states(struct d3dx9_sprite *object)
Definition: sprite.c:195
#define D3DXSPRITE_FLAGLIMIT
Definition: sprite.c:28
#define IDirect3DDevice9_SetVertexDeclaration(p, a)
Definition: d3d9.h:1594
#define IDirect3DDevice9_EndStateBlock(p, a)
Definition: d3d9.h:1568
#define D3DXSPRITE_OBJECTSPACE
Definition: d3dx9core.h:35

◆ 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 340 of file sprite.c.

342 {
343  struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
344  D3DSURFACE_DESC texdesc;
345 
346  TRACE("iface %p, texture %p, rect %s, center %p, position %p, color 0x%08x.\n",
347  iface, texture, wine_dbgstr_rect(rect), center, position, color);
348 
349  if(texture==NULL) return D3DERR_INVALIDCALL;
350  if(!This->ready) return D3DERR_INVALIDCALL;
351 
352  if (!This->allocated_sprites)
353  {
354  This->sprites = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32 * sizeof(*This->sprites));
355  This->allocated_sprites = 32;
356  }
357  else if (This->allocated_sprites <= This->sprite_count)
358  {
359  This->allocated_sprites += This->allocated_sprites / 2;
361  This->sprites, This->allocated_sprites * sizeof(*This->sprites));
362  }
363  This->sprites[This->sprite_count].texture=texture;
364  if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
366 
367  /* Reuse the texture desc if possible */
368  if(This->sprite_count) {
369  if(This->sprites[This->sprite_count-1].texture!=texture) {
371  } else {
372  texdesc.Width=This->sprites[This->sprite_count-1].texw;
373  texdesc.Height=This->sprites[This->sprite_count-1].texh;
374  }
375  } else IDirect3DTexture9_GetLevelDesc(texture, 0, &texdesc);
376 
377  This->sprites[This->sprite_count].texw=texdesc.Width;
378  This->sprites[This->sprite_count].texh=texdesc.Height;
379 
380  if (rect)
381  This->sprites[This->sprite_count].rect = *rect;
382  else
383  SetRect(&This->sprites[This->sprite_count].rect, 0, 0, texdesc.Width, texdesc.Height);
384 
385  if(center==NULL) {
386  This->sprites[This->sprite_count].center.x=0.0f;
387  This->sprites[This->sprite_count].center.y=0.0f;
388  This->sprites[This->sprite_count].center.z=0.0f;
389  } else This->sprites[This->sprite_count].center=*center;
390 
391  if(position==NULL) {
392  This->sprites[This->sprite_count].pos.x=0.0f;
393  This->sprites[This->sprite_count].pos.y=0.0f;
394  This->sprites[This->sprite_count].pos.z=0.0f;
395  } else This->sprites[This->sprite_count].pos=*position;
396 
397  This->sprites[This->sprite_count].color=color;
398  This->sprites[This->sprite_count].transform=This->transform;
399  This->sprite_count++;
400 
401  return D3D_OK;
402 }
#define D3DERR_INVALIDCALL
#define D3DXSPRITE_DO_NOT_ADDREF_TEXTURE
Definition: d3dx9core.h:41
#define IDirect3DTexture9_AddRef(p)
Definition: d3d9.h:1013
& rect
Definition: startmenu.cpp:1413
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
GLuint color
Definition: glext.h:6243
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLuint texture
Definition: glext.h:6295
const char * wine_dbgstr_rect(const RECT *rect)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define D3D_OK
Definition: d3d.h:106
#define HeapReAlloc
Definition: compat.h:393
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

◆ d3dx9_sprite_End()

static HRESULT WINAPI d3dx9_sprite_End ( ID3DXSprite *  iface)
static

Definition at line 478 of file sprite.c.

479 {
480  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
481 
482  TRACE("iface %p.\n", iface);
483 
484  if (!sprite->ready)
485  return D3DERR_INVALIDCALL;
486 
487  ID3DXSprite_Flush(iface);
488 
489  if (sprite->stateblock && !(sprite->flags & D3DXSPRITE_DONOTSAVESTATE))
490  IDirect3DStateBlock9_Apply(sprite->stateblock); /* Restore old state */
491 
492  sprite->ready = FALSE;
493 
494  return D3D_OK;
495 }
#define D3DERR_INVALIDCALL
#define IDirect3DStateBlock9_Apply(p)
Definition: d3d9.h:1304
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
#define D3DXSPRITE_DONOTSAVESTATE
Definition: d3dx9core.h:33
#define TRACE(s)
Definition: solgame.cpp:4
#define ID3DXSprite_Flush(p)
Definition: d3dx9core.h:451
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106

◆ d3dx9_sprite_Flush()

static HRESULT WINAPI d3dx9_sprite_Flush ( ID3DXSprite *  iface)
static

Definition at line 404 of file sprite.c.

405 {
406  struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
407  struct sprite_vertex *vertices;
408  int i, count=0, start;
409 
410  TRACE("iface %p.\n", iface);
411 
412  if(!This->ready) return D3DERR_INVALIDCALL;
413  if(!This->sprite_count) return D3D_OK;
414 
415 /* TODO: use of a vertex buffer here */
416  vertices = HeapAlloc(GetProcessHeap(), 0, sizeof(*vertices) * 6 * This->sprite_count);
417 
418  for(start=0;start<This->sprite_count;start+=count,count=0) {
419  i=start;
420  while(i<This->sprite_count &&
421  (count==0 || This->sprites[i].texture==This->sprites[i-1].texture)) {
422  float spritewidth=(float)This->sprites[i].rect.right-(float)This->sprites[i].rect.left;
423  float spriteheight=(float)This->sprites[i].rect.bottom-(float)This->sprites[i].rect.top;
424 
425  vertices[6*i ].pos.x = This->sprites[i].pos.x - This->sprites[i].center.x;
426  vertices[6*i ].pos.y = This->sprites[i].pos.y - This->sprites[i].center.y;
427  vertices[6*i ].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
428  vertices[6*i+1].pos.x = spritewidth + This->sprites[i].pos.x - This->sprites[i].center.x;
429  vertices[6*i+1].pos.y = This->sprites[i].pos.y - This->sprites[i].center.y;
430  vertices[6*i+1].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
431  vertices[6*i+2].pos.x = spritewidth + This->sprites[i].pos.x - This->sprites[i].center.x;
432  vertices[6*i+2].pos.y = spriteheight + This->sprites[i].pos.y - This->sprites[i].center.y;
433  vertices[6*i+2].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
434  vertices[6*i+3].pos.x = This->sprites[i].pos.x - This->sprites[i].center.x;
435  vertices[6*i+3].pos.y = spriteheight + This->sprites[i].pos.y - This->sprites[i].center.y;
436  vertices[6*i+3].pos.z = This->sprites[i].pos.z - This->sprites[i].center.z;
437  vertices[6*i ].col = This->sprites[i].color;
438  vertices[6*i+1].col = This->sprites[i].color;
439  vertices[6*i+2].col = This->sprites[i].color;
440  vertices[6*i+3].col = This->sprites[i].color;
441  vertices[6*i ].tex.x = (float)This->sprites[i].rect.left / (float)This->sprites[i].texw;
442  vertices[6*i ].tex.y = (float)This->sprites[i].rect.top / (float)This->sprites[i].texh;
443  vertices[6*i+1].tex.x = (float)This->sprites[i].rect.right / (float)This->sprites[i].texw;
444  vertices[6*i+1].tex.y = (float)This->sprites[i].rect.top / (float)This->sprites[i].texh;
445  vertices[6*i+2].tex.x = (float)This->sprites[i].rect.right / (float)This->sprites[i].texw;
446  vertices[6*i+2].tex.y = (float)This->sprites[i].rect.bottom / (float)This->sprites[i].texh;
447  vertices[6*i+3].tex.x = (float)This->sprites[i].rect.left / (float)This->sprites[i].texw;
448  vertices[6*i+3].tex.y = (float)This->sprites[i].rect.bottom / (float)This->sprites[i].texh;
449 
450  vertices[6*i+4]=vertices[6*i];
451  vertices[6*i+5]=vertices[6*i+2];
452 
453  D3DXVec3TransformCoordArray(&vertices[6 * i].pos, sizeof(*vertices),
454  &vertices[6 * i].pos, sizeof(*vertices), &This->sprites[i].transform, 6);
455  count++;
456  i++;
457  }
458 
459  IDirect3DDevice9_SetTexture(This->device, 0, (struct IDirect3DBaseTexture9 *)This->sprites[start].texture);
461 
463  2 * count, vertices + 6 * start, sizeof(*vertices));
464  }
465  HeapFree(GetProcessHeap(), 0, vertices);
466 
467  if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
468  for(i=0;i<This->sprite_count;i++)
469  IDirect3DTexture9_Release(This->sprites[i].texture);
470 
471  This->sprite_count=0;
472 
473  /* Flush may be called more than once, so we don't reset This->ready here */
474 
475  return D3D_OK;
476 }
FLOAT y
Definition: d3dx9math.h:64
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
#define D3DERR_INVALIDCALL
#define D3DXSPRITE_DO_NOT_ADDREF_TEXTURE
Definition: d3dx9core.h:41
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
FLOAT x
Definition: d3dx9math.h:64
D3DXVECTOR3 pos
Definition: sprite.c:32
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_SetTexture(p, a, b)
Definition: d3d9.h:1572
GLuint start
Definition: gl.h:1545
D3DXVECTOR3 *WINAPI D3DXVec3TransformCoordArray(D3DXVECTOR3 *out, UINT outstride, const D3DXVECTOR3 *in, UINT instride, const D3DXMATRIX *matrix, UINT elements)
Definition: math.c:1957
DWORD col
Definition: sprite.c:33
D3DXVECTOR2 tex
Definition: sprite.c:34
#define IDirect3DDevice9_SetVertexDeclaration(p, a)
Definition: d3d9.h:1594
#define IDirect3DDevice9_DrawPrimitiveUP(p, a, b, c, d)
Definition: d3d9.h:1590
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ d3dx9_sprite_GetDevice()

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

Definition at line 138 of file sprite.c.

139 {
140  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
141 
142  TRACE("iface %p, device %p.\n", iface, device);
143 
144  if (!device)
145  return D3DERR_INVALIDCALL;
146  *device = sprite->device;
148 
149  return D3D_OK;
150 }
#define D3DERR_INVALIDCALL
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106

◆ d3dx9_sprite_GetTransform()

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

Definition at line 152 of file sprite.c.

153 {
154  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
155 
156  TRACE("iface %p, transform %p.\n", iface, transform);
157 
158  if (!transform)
159  return D3DERR_INVALIDCALL;
161 
162  return D3D_OK;
163 }
#define D3DERR_INVALIDCALL
D3DXMATRIX transform
Definition: sprite.c:45
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
#define TRACE(s)
Definition: solgame.cpp:4
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106
GLuint GLenum GLenum transform
Definition: glext.h:9407

◆ d3dx9_sprite_OnLostDevice()

static HRESULT WINAPI d3dx9_sprite_OnLostDevice ( ID3DXSprite *  iface)
static

Definition at line 497 of file sprite.c.

498 {
499  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
500 
501  TRACE("iface %p.\n", iface);
502 
503  if (sprite->stateblock)
505  if (sprite->vdecl)
507  sprite->vdecl = NULL;
508  sprite->stateblock = NULL;
509 
510  /* Reset some variables */
512 
513  return D3D_OK;
514 }
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DStateBlock9_Release(p)
Definition: d3d9.h:1300
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106
#define ID3DXSprite_OnResetDevice(p)
Definition: d3dx9core.h:454
#define IDirect3DVertexDeclaration9_Release(p)
Definition: d3d9.h:1185

◆ d3dx9_sprite_OnResetDevice()

static HRESULT WINAPI d3dx9_sprite_OnResetDevice ( ID3DXSprite *  iface)
static

Definition at line 516 of file sprite.c.

517 {
518  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
519  int i;
520 
521  TRACE("iface %p.\n", iface);
522 
523  for (i = 0; i < sprite->sprite_count; ++i)
524  {
525  if (sprite->sprites[i].texture)
527  }
528 
529  sprite->sprite_count = 0;
530  sprite->flags = 0;
531  sprite->ready = FALSE;
532 
533  /* keep matrices */
534  /* device objects get restored on Begin */
535 
536  return D3D_OK;
537 }
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
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
IDirect3DTexture9 * texture
Definition: sprite.c:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106

◆ d3dx9_sprite_QueryInterface()

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

Definition at line 76 of file sprite.c.

77 {
78  TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
79 
80  if (IsEqualGUID(riid, &IID_ID3DXSprite)
82  {
83  IUnknown_AddRef(iface);
84  *out = iface;
85  return S_OK;
86  }
87 
88  WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
89 
90  *out = NULL;
91  return E_NOINTERFACE;
92 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static FILE * out
Definition: regtests2xml.c:44
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ d3dx9_sprite_Release()

static ULONG WINAPI d3dx9_sprite_Release ( ID3DXSprite *  iface)
static

Definition at line 104 of file sprite.c.

105 {
106  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
107  ULONG refcount = InterlockedDecrement(&sprite->ref);
108 
109  TRACE("%p decreasing refcount to %u.\n", sprite, refcount);
110 
111  if (!refcount)
112  {
113  if (sprite->sprites)
114  {
115  int i;
116 
117  for (i = 0; i < sprite->sprite_count; ++i)
118  {
119  if (sprite->sprites[i].texture)
121  }
122 
123  HeapFree(GetProcessHeap(), 0, sprite->sprites);
124  }
125 
126  if (sprite->stateblock)
128  if (sprite->vdecl)
130  if (sprite->device)
133  }
134 
135  return refcount;
136 }
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
IDirect3DTexture9 * texture
Definition: sprite.c:39
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DStateBlock9_Release(p)
Definition: d3d9.h:1300
Definition: sprite.c:37
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
#define IDirect3DVertexDeclaration9_Release(p)
Definition: d3d9.h:1185

◆ d3dx9_sprite_SetTransform()

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

Definition at line 165 of file sprite.c.

166 {
167  struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
168 
169  TRACE("iface %p, transform %p.\n", iface, transform);
170 
171  if (!transform)
172  return D3DERR_INVALIDCALL;
174 
175  return D3D_OK;
176 }
#define D3DERR_INVALIDCALL
D3DXMATRIX transform
Definition: sprite.c:45
static struct d3dx9_sprite * impl_from_ID3DXSprite(ID3DXSprite *iface)
Definition: sprite.c:71
#define TRACE(s)
Definition: solgame.cpp:4
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106
GLuint GLenum GLenum transform
Definition: glext.h:9407

◆ d3dx9_sprite_SetWorldViewLH()

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

Definition at line 186 of file sprite.c.

188 {
189  FIXME("iface %p, world %p, view %p stub!\n", iface, world, view);
190 
191  return E_NOTIMPL;
192 }
#define FIXME(fmt,...)
Definition: debug.h:110
#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 178 of file sprite.c.

180 {
181  FIXME("iface %p, world %p, view %p stub!\n", iface, world, view);
182 
183  return E_NOTIMPL;
184 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ D3DXCreateSprite()

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

Definition at line 557 of file sprite.c.

558 {
559  struct d3dx9_sprite *object;
560  D3DCAPS9 caps;
561 
562  TRACE("device %p, sprite %p.\n", device, sprite);
563 
564  if(device==NULL || sprite==NULL) return D3DERR_INVALIDCALL;
565 
566  if (!(object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
567  {
568  *sprite = NULL;
569  return E_OUTOFMEMORY;
570  }
571  object->ID3DXSprite_iface.lpVtbl = &d3dx9_sprite_vtbl;
572  object->ref=1;
573  object->device=device;
574  IUnknown_AddRef(device);
575 
576  object->vdecl=NULL;
577  object->stateblock=NULL;
578 
579  D3DXMatrixIdentity(&object->transform);
580  D3DXMatrixIdentity(&object->view);
581 
583  object->texfilter_caps=caps.TextureFilterCaps;
584  object->maxanisotropy=caps.MaxAnisotropy;
585  object->alphacmp_caps=caps.AlphaCmpCaps;
586 
587  ID3DXSprite_OnResetDevice(&object->ID3DXSprite_iface);
588 
589  object->sprites=NULL;
590  object->allocated_sprites=0;
591  *sprite=&object->ID3DXSprite_iface;
592 
593  return D3D_OK;
594 }
#define D3DERR_INVALIDCALL
DWORD TextureFilterCaps
Definition: d3d9caps.h:280
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
IDirect3DDevice9 * device
Definition: sprite.c:53
DWORD AlphaCmpCaps
Definition: d3d9caps.h:277
Definition: sprite.c:37
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static const ID3DXSpriteVtbl d3dx9_sprite_vtbl
Definition: sprite.c:539
DWORD MaxAnisotropy
Definition: d3d9caps.h:291
#define ID3DXSprite_OnResetDevice(p)
Definition: d3dx9core.h:454
void * object
Definition: jmemsys.h:48

Referenced by ID3DXFontImpl_DrawTextW().

◆ impl_from_ID3DXSprite()

static struct d3dx9_sprite* impl_from_ID3DXSprite ( ID3DXSprite *  iface)
inlinestatic

Definition at line 71 of file sprite.c.

72 {
73  return CONTAINING_RECORD(iface, struct d3dx9_sprite, ID3DXSprite_iface);
74 }
ID3DXSprite ID3DXSprite_iface
Definition: sprite.c:50
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by d3dx9_sprite_AddRef(), d3dx9_sprite_Begin(), d3dx9_sprite_Draw(), d3dx9_sprite_End(), d3dx9_sprite_Flush(), d3dx9_sprite_GetDevice(), d3dx9_sprite_GetTransform(), d3dx9_sprite_OnLostDevice(), d3dx9_sprite_OnResetDevice(), d3dx9_sprite_Release(), and d3dx9_sprite_SetTransform().

◆ set_states()

static void set_states ( struct d3dx9_sprite object)
static

Definition at line 195 of file sprite.c.

196 {
197  D3DXMATRIX mat;
198  D3DVIEWPORT9 vp;
199 
200  /* Miscellaneous stuff */
203  IDirect3DDevice9_SetNPatchMode(object->device, 0.0f);
204 
205  /* Render states */
232 
233  /* Texture stage states */
244 
245  /* Sampler states */
248 
249  if(object->texfilter_caps & D3DPTFILTERCAPS_MAGFANISOTROPIC)
252 
255 
256  if(object->texfilter_caps & D3DPTFILTERCAPS_MINFANISOTROPIC)
259 
260  if(object->texfilter_caps & D3DPTFILTERCAPS_MIPFLINEAR)
263 
266 
267  /* Matrices */
268  D3DXMatrixIdentity(&mat);
271  IDirect3DDevice9_GetViewport(object->device, &vp);
272  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);
274 }
#define IDirect3DDevice9_SetTextureStageState(p, a, b, c)
Definition: d3d9.h:1574
#define TRUE
Definition: types.h:120
#define D3DPTFILTERCAPS_MAGFANISOTROPIC
Definition: d3d8caps.h:135
#define D3DCOLORWRITEENABLE_ALPHA
Definition: d3d8types.h:151
static const MAT2 mat
Definition: font.c:66
#define D3DCOLORWRITEENABLE_RED
Definition: d3d8types.h:148
#define D3DPTFILTERCAPS_MIPFLINEAR
Definition: d3d8caps.h:132
smooth NULL
Definition: ftsmooth.c:416
#define D3DTA_TEXTURE
Definition: d3d8types.h:141
#define IDirect3DDevice9_SetPixelShader(p, a)
Definition: d3d9.h:1614
#define IDirect3DDevice9_GetViewport(p, a)
Definition: d3d9.h:1555
D3DXMATRIX *WINAPI D3DXMatrixOrthoOffCenterLH(D3DXMATRIX *pout, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf)
Definition: math.c:439
#define D3DCOLORWRITEENABLE_GREEN
Definition: d3d8types.h:149
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1551
#define D3DPTFILTERCAPS_MINFANISOTROPIC
Definition: d3d8caps.h:130
#define IDirect3DDevice9_SetVertexShader(p, a)
Definition: d3d9.h:1599
#define D3DCOLORWRITEENABLE_BLUE
Definition: d3d8types.h:150
#define IDirect3DDevice9_SetRenderState(p, a, b)
Definition: d3d9.h:1564
#define D3DTS_WORLD
Definition: d3d8types.h:85
#define D3DTA_DIFFUSE
Definition: d3d8types.h:139
#define IDirect3DDevice9_SetNPatchMode(p, a)
Definition: d3d9.h:1586
#define IDirect3DDevice9_SetSamplerState(p, a, b, c)
Definition: d3d9.h:1576

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_Flush(ID3DXSprite *iface)
Definition: sprite.c:404
static HRESULT WINAPI d3dx9_sprite_SetWorldViewLH(ID3DXSprite *iface, const D3DXMATRIX *world, const D3DXMATRIX *view)
Definition: sprite.c:186
static HRESULT WINAPI d3dx9_sprite_End(ID3DXSprite *iface)
Definition: sprite.c:478
static HRESULT WINAPI d3dx9_sprite_QueryInterface(ID3DXSprite *iface, REFIID riid, void **out)
Definition: sprite.c:76
static HRESULT WINAPI d3dx9_sprite_OnLostDevice(ID3DXSprite *iface)
Definition: sprite.c:497
static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
Definition: sprite.c:104
static HRESULT WINAPI d3dx9_sprite_SetTransform(ID3DXSprite *iface, const D3DXMATRIX *transform)
Definition: sprite.c:165
static HRESULT WINAPI d3dx9_sprite_Begin(ID3DXSprite *iface, DWORD flags)
Definition: sprite.c:276
static HRESULT WINAPI d3dx9_sprite_GetTransform(ID3DXSprite *iface, D3DXMATRIX *transform)
Definition: sprite.c:152
static HRESULT WINAPI d3dx9_sprite_GetDevice(struct ID3DXSprite *iface, struct IDirect3DDevice9 **device)
Definition: sprite.c:138
static ULONG WINAPI d3dx9_sprite_AddRef(ID3DXSprite *iface)
Definition: sprite.c:94
static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *texture, const RECT *rect, const D3DXVECTOR3 *center, const D3DXVECTOR3 *position, D3DCOLOR color)
Definition: sprite.c:340
static HRESULT WINAPI d3dx9_sprite_SetWorldViewRH(ID3DXSprite *iface, const D3DXMATRIX *world, const D3DXMATRIX *view)
Definition: sprite.c:178
static HRESULT WINAPI d3dx9_sprite_OnResetDevice(ID3DXSprite *iface)
Definition: sprite.c:516

Definition at line 539 of file sprite.c.

Referenced by D3DXCreateSprite().