ReactOS  0.4.15-dev-3295-gaa8fc87
texture.c File Reference
#include <assert.h>
#include "d3dx9_private.h"
Include dependency graph for texture.c:

Go to the source code of this file.

Enumerations

enum  cube_coord {
  XCOORD = 0, XCOORDINV = 1, YCOORD = 2, YCOORDINV = 3,
  ZERO = 4, ONE = 5, XCOORD = 0, XCOORDINV = 1,
  YCOORD = 2, YCOORDINV = 3, ZERO = 4, ONE = 5
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static BOOL is_pow2 (UINT num)
 
static HRESULT get_surface (D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
 
HRESULT WINAPI D3DXFilterTexture (IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
 
static D3DFORMAT get_replacement_format (D3DFORMAT format)
 
static HRESULT check_texture_requirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
 
HRESULT WINAPI D3DXCheckTextureRequirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCheckCubeTextureRequirements (struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCheckVolumeTextureRequirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCreateTexture (struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
 
static D3DFORMAT get_alpha_replacement_format (D3DFORMAT format)
 
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileExW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileExA (struct IDirect3DDevice9 *device, const char *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileA (struct IDirect3DDevice9 *device, const char *srcfile, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceExA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceExW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTexture (struct IDirect3DDevice9 *device, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DCubeTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *data, UINT datasize, struct IDirect3DCubeTexture9 **texture)
 
HRESULT WINAPI D3DXCreateVolumeTexture (struct IDirect3DDevice9 *device, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DVolumeTexture9 **texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileA (IDirect3DDevice9 *device, const char *filename, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileW (IDirect3DDevice9 *device, const WCHAR *filename, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA (IDirect3DDevice9 *device, const char *filename, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileExW (IDirect3DDevice9 *device, const WCHAR *filename, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory (IDirect3DDevice9 *device, const void *data, UINT data_size, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx (IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
 
static void fill_texture (const struct pixel_format_desc *format, BYTE *pos, const D3DXVECTOR4 *value)
 
HRESULT WINAPI D3DXFillTexture (struct IDirect3DTexture9 *texture, LPD3DXFILL2D function, void *funcdata)
 
HRESULT WINAPI D3DXFillTextureTX (struct IDirect3DTexture9 *texture, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx (IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileA (IDirect3DDevice9 *device, const char *src_filename, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileW (IDirect3DDevice9 *device, const WCHAR *src_filename, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileExA (IDirect3DDevice9 *device, const char *src_filename, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *image_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileExW (IDirect3DDevice9 *device, const WCHAR *src_filename, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *image_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
 
static float get_cube_coord (enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
 
HRESULT WINAPI D3DXFillCubeTexture (struct IDirect3DCubeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
 
HRESULT WINAPI D3DXFillCubeTextureTX (struct IDirect3DCubeTexture9 *texture, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXFillVolumeTexture (struct IDirect3DVolumeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
 
HRESULT WINAPI D3DXFillVolumeTextureTX (struct IDirect3DVolumeTexture9 *texture, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXSaveTextureToFileA (const char *dst_filename, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
 
HRESULT WINAPI D3DXSaveTextureToFileW (const WCHAR *dst_filename, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
 
HRESULT WINAPI D3DXSaveTextureToFileInMemory (ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
 
HRESULT WINAPI D3DXComputeNormalMap (IDirect3DTexture9 *texture, IDirect3DTexture9 *src_texture, const PALETTEENTRY *src_palette, DWORD flags, DWORD channel, float amplitude)
 

Enumeration Type Documentation

◆ cube_coord

Enumerator
XCOORD 
XCOORDINV 
YCOORD 
YCOORDINV 
ZERO 
ONE 
XCOORD 
XCOORDINV 
YCOORD 
YCOORDINV 
ZERO 
ONE 

Definition at line 1663 of file texture.c.

1664 {
1665  XCOORD = 0,
1666  XCOORDINV = 1,
1667  YCOORD = 2,
1668  YCOORDINV = 3,
1669  ZERO = 4,
1670  ONE = 5
1671 };
Definition: texture.c:1670
Definition: texture.c:1669

Function Documentation

◆ check_texture_requirements()

static HRESULT check_texture_requirements ( struct IDirect3DDevice9 *  device,
UINT width,
UINT height,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool,
D3DRESOURCETYPE  resource_type 
)
static

Definition at line 202 of file texture.c.

204 {
205  UINT w = (width && *width) ? *width : 1;
206  UINT h = (height && *height) ? *height : 1;
207  D3DCAPS9 caps;
209  IDirect3D9 *d3d = NULL;
211  HRESULT hr;
212  D3DFORMAT usedformat = D3DFMT_UNKNOWN;
213  const struct pixel_format_desc *fmt;
214 
215  if (!device)
216  return D3DERR_INVALIDCALL;
217 
218  /* usage */
219  if (usage == D3DX_DEFAULT)
220  usage = 0;
222  return D3DERR_INVALIDCALL;
223 
224  /* pool */
226  return D3DERR_INVALIDCALL;
227 
228  /* format */
229  if (format)
230  {
231  TRACE("Requested format %x\n", *format);
232  usedformat = *format;
233  }
234 
236 
237  if (FAILED(hr))
238  goto cleanup;
239 
241 
242  if (FAILED(hr))
243  goto cleanup;
244 
246 
247  if (FAILED(hr))
248  goto cleanup;
249 
250  if ((usedformat == D3DFMT_UNKNOWN) || (usedformat == D3DX_DEFAULT))
251  usedformat = D3DFMT_A8R8G8B8;
252 
253  fmt = get_format_info(usedformat);
254 
255  hr = IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType, mode.Format,
256  usage, resource_type, usedformat);
257  if (FAILED(hr))
258  {
259  BOOL allow_24bits;
260  int bestscore = INT_MIN, i = 0, j;
261  unsigned int channels;
262  const struct pixel_format_desc *curfmt, *bestfmt = NULL;
263 
264  TRACE("Requested format is not supported, looking for a fallback.\n");
265 
266  if (!fmt)
267  {
268  FIXME("Pixel format %x not handled\n", usedformat);
269  goto cleanup;
270  }
272 
273  allow_24bits = fmt->bytes_per_pixel == 3;
274  channels = !!fmt->bits[0] + !!fmt->bits[1] + !!fmt->bits[2] + !!fmt->bits[3];
275  usedformat = D3DFMT_UNKNOWN;
276 
277  while ((curfmt = get_format_info_idx(i)))
278  {
279  unsigned int curchannels = !!curfmt->bits[0] + !!curfmt->bits[1]
280  + !!curfmt->bits[2] + !!curfmt->bits[3];
281  int score;
282 
283  i++;
284 
285  if (curchannels < channels)
286  continue;
287  if (curfmt->bytes_per_pixel == 3 && !allow_24bits)
288  continue;
289 
290  hr = IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
291  mode.Format, usage, resource_type, curfmt->format);
292  if (FAILED(hr))
293  continue;
294 
295  /* This format can be used, let's evaluate it.
296  Weights chosen quite arbitrarily... */
297  score = 512 * (curfmt->type == fmt->type);
298  score -= 32 * (curchannels - channels);
299 
300  for (j = 0; j < 4; j++)
301  {
302  int diff = curfmt->bits[j] - fmt->bits[j];
303  score -= (diff < 0 ? -diff * 8 : diff) * (j == 0 ? 1 : 2);
304  }
305 
306  if (score > bestscore)
307  {
308  bestscore = score;
309  usedformat = curfmt->format;
310  bestfmt = curfmt;
311  }
312  }
313  if (!bestfmt)
314  {
316  goto cleanup;
317  }
318  fmt = bestfmt;
319  hr = D3D_OK;
320  }
321 
323  return D3DERR_INVALIDCALL;
324 
325  if ((w == D3DX_DEFAULT) && (h == D3DX_DEFAULT))
326  w = h = 256;
327  else if (w == D3DX_DEFAULT)
328  w = (height ? h : 256);
329  else if (h == D3DX_DEFAULT)
330  h = (width ? w : 256);
331 
332  assert(!(fmt->block_width & (fmt->block_width - 1)));
333  assert(!(fmt->block_height & (fmt->block_height - 1)));
334  if (w & (fmt->block_width - 1))
335  w = (w + fmt->block_width) & ~(fmt->block_width - 1);
336  if (h & (fmt->block_height - 1))
337  h = (h + fmt->block_height) & ~(fmt->block_height - 1);
338 
339  if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
340  w = make_pow2(w);
341 
342  if (w > caps.MaxTextureWidth)
343  w = caps.MaxTextureWidth;
344 
345  if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(h)))
346  h = make_pow2(h);
347 
348  if (h > caps.MaxTextureHeight)
349  h = caps.MaxTextureHeight;
350 
352  {
353  if (w > h)
354  h = w;
355  else
356  w = h;
357  }
358 
359  if (width)
360  *width = w;
361 
362  if (height)
363  *height = h;
364 
365  if (miplevels && (usage & D3DUSAGE_AUTOGENMIPMAP))
366  {
367  if (*miplevels > 1)
368  *miplevels = 0;
369  }
370  else if (miplevels)
371  {
372  UINT max_mipmaps = 1;
373 
374  if (!width && !height)
375  max_mipmaps = 9; /* number of mipmaps in a 256x256 texture */
376  else
377  {
378  UINT max_dimen = max(w, h);
379 
380  while (max_dimen > 1)
381  {
382  max_dimen >>= 1;
383  max_mipmaps++;
384  }
385  }
386 
387  if (*miplevels == 0 || *miplevels > max_mipmaps)
388  *miplevels = max_mipmaps;
389  }
390 
391 cleanup:
392 
393  if (d3d)
394  IDirect3D9_Release(d3d);
395 
396  if (FAILED(hr))
397  return hr;
398 
399  if (usedformat == D3DFMT_UNKNOWN)
400  {
401  WARN("Couldn't find a suitable pixel format\n");
402  return D3DERR_NOTAVAILABLE;
403  }
404 
405  TRACE("Format chosen: %x\n", usedformat);
406  if (format)
407  *format = usedformat;
408 
409  return D3D_OK;
410 }
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
GLint GLint GLsizei width
Definition: gl.h:1546
#define max(a, b)
Definition: svc.c:63
#define D3DPTEXTURECAPS_POW2
Definition: d3d8caps.h:114
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DDevice9_GetCreationParameters(p, a)
Definition: d3d9.h:1516
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define WARN(fmt,...)
Definition: debug.h:112
int bits
Definition: dsound.c:944
#define D3DUSAGE_POINTS
Definition: d3d8types.h:96
const char * fmt
Definition: wsprintf.c:30
DWORD MaxTextureHeight
Definition: d3d9caps.h:287
#define D3DUSAGE_DONOTCLIP
Definition: d3d8types.h:95
#define D3DERR_INVALIDCALL
#define assert(x)
Definition: debug.h:53
int This channels
Definition: rdpsnd_libao.c:37
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
DWORD MaxTextureWidth
Definition: d3d9caps.h:286
#define FIXME(fmt,...)
Definition: debug.h:111
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
#define D3DPTEXTURECAPS_SQUAREONLY
Definition: d3d8caps.h:116
const struct pixel_format_desc * get_format_info_idx(int idx) DECLSPEC_HIDDEN
Definition: util.c:226
enum _D3DFORMAT D3DFORMAT
#define IDirect3DDevice9_GetDisplayMode(p, a, b)
Definition: d3d9.h:1515
#define D3DUSAGE_NPATCHES
Definition: d3d8types.h:98
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
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1513
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
enum format_type type
Definition: d3dx9_private.h:66
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static uint32_t make_pow2(uint32_t num)
GLenum mode
Definition: glext.h:6217
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define INT_MIN
Definition: limits.h:39
#define D3D_OK
Definition: d3d.h:106
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_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
char * cleanup(char *str)
Definition: wpickclick.c:99
static D3DFORMAT get_replacement_format(D3DFORMAT format)
Definition: texture.c:175
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
static BOOL is_pow2(UINT num)
Definition: texture.c:32
Definition: dsound.c:943

Referenced by D3DXCheckCubeTextureRequirements(), D3DXCheckTextureRequirements(), and D3DXCheckVolumeTextureRequirements().

◆ D3DXCheckCubeTextureRequirements()

HRESULT WINAPI D3DXCheckCubeTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT size,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool 
)

Definition at line 421 of file texture.c.

423 {
424  D3DCAPS9 caps;
425  UINT s = (size && *size) ? *size : 256;
426  HRESULT hr;
427 
428  TRACE("(%p, %p, %p, %u, %p, %u)\n", device, size, miplevels, usage, format, pool);
429 
430  if (s == D3DX_DEFAULT)
431  s = 256;
432 
434  return D3DERR_INVALIDCALL;
435 
436  if (!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP))
437  return D3DERR_NOTAVAILABLE;
438 
440  s = make_pow2(s);
441 
443 
445  {
446  if(miplevels)
447  *miplevels = 1;
448  }
449 
450  if (size)
451  *size = s;
452 
453  return hr;
454 }
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
#define D3DPTEXTURECAPS_CUBEMAP_POW2
Definition: d3d8caps.h:126
#define D3DERR_INVALIDCALL
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
static HRESULT check_texture_requirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
Definition: texture.c:202
#define D3DPTEXTURECAPS_CUBEMAP
Definition: d3d8caps.h:121
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLdouble s
Definition: gl.h:2039
static uint32_t make_pow2(uint32_t num)
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
unsigned int UINT
Definition: ndis.h:50
#define D3DPTEXTURECAPS_MIPCUBEMAP
Definition: d3d8caps.h:125
static BOOL is_pow2(UINT num)
Definition: texture.c:32

Referenced by D3DXCreateCubeTexture(), D3DXCreateCubeTextureFromFileInMemoryEx(), and test_D3DXCheckCubeTextureRequirements().

◆ D3DXCheckTextureRequirements()

HRESULT WINAPI D3DXCheckTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT width,
UINT height,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool 
)

Definition at line 412 of file texture.c.

414 {
415  TRACE("device %p, width %p, height %p, miplevels %p, usage %u, format %p, pool %u.\n",
416  device, width, height, miplevels, usage, format, pool);
417 
419 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
static HRESULT check_texture_requirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
Definition: texture.c:202
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546

Referenced by D3DXCreateRenderToEnvMap(), D3DXCreateTexture(), D3DXCreateTextureFromFileInMemoryEx(), and test_D3DXCheckTextureRequirements().

◆ D3DXCheckVolumeTextureRequirements()

HRESULT WINAPI D3DXCheckVolumeTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT width,
UINT height,
UINT depth,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool 
)

Definition at line 456 of file texture.c.

458 {
459  D3DCAPS9 caps;
460  UINT w = width ? *width : D3DX_DEFAULT;
462  UINT d = (depth && *depth) ? *depth : 1;
463  HRESULT hr;
464 
465  TRACE("(%p, %p, %p, %p, %p, %u, %p, %u)\n", device, width, height, depth, miplevels,
466  usage, format, pool);
467 
469  return D3DERR_INVALIDCALL;
470 
472  return D3DERR_NOTAVAILABLE;
473 
475  if (d == D3DX_DEFAULT)
476  d = 1;
477 
479  (!is_pow2(w) || !is_pow2(h) || !is_pow2(d)))
480  {
481  w = make_pow2(w);
482  h = make_pow2(h);
483  d = make_pow2(d);
484  }
485 
486  if (w > caps.MaxVolumeExtent)
487  w = caps.MaxVolumeExtent;
488  if (h > caps.MaxVolumeExtent)
489  h = caps.MaxVolumeExtent;
490  if (d > caps.MaxVolumeExtent)
491  d = caps.MaxVolumeExtent;
492 
493  if (miplevels)
494  {
496  *miplevels = 1;
497  else if ((usage & D3DUSAGE_AUTOGENMIPMAP))
498  {
499  if (*miplevels > 1)
500  *miplevels = 0;
501  }
502  else
503  {
504  UINT max_mipmaps = 1;
505  UINT max_dimen = max(max(w, h), d);
506 
507  while (max_dimen > 1)
508  {
509  max_dimen >>= 1;
510  max_mipmaps++;
511  }
512 
513  if (*miplevels == 0 || *miplevels > max_mipmaps)
514  *miplevels = max_mipmaps;
515  }
516  }
517 
518  if (width)
519  *width = w;
520  if (height)
521  *height = h;
522  if (depth)
523  *depth = d;
524 
525  return hr;
526 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define max(a, b)
Definition: svc.c:63
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define D3DERR_INVALIDCALL
#define D3DPTEXTURECAPS_MIPVOLUMEMAP
Definition: d3d8caps.h:124
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
DWORD MaxVolumeExtent
Definition: d3d9caps.h:288
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
static HRESULT check_texture_requirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
Definition: texture.c:202
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static uint32_t make_pow2(uint32_t num)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2
Definition: d3d8caps.h:127
static BOOL is_pow2(UINT num)
Definition: texture.c:32
#define D3DPTEXTURECAPS_VOLUMEMAP
Definition: d3d8caps.h:122
#define d
Definition: ke_i.h:81

Referenced by D3DXCreateVolumeTexture(), D3DXCreateVolumeTextureFromFileInMemoryEx(), and test_D3DXCheckVolumeTextureRequirements().

◆ D3DXComputeNormalMap()

HRESULT WINAPI D3DXComputeNormalMap ( IDirect3DTexture9 *  texture,
IDirect3DTexture9 *  src_texture,
const PALETTEENTRY src_palette,
DWORD  flags,
DWORD  channel,
float  amplitude 
)

Definition at line 1927 of file texture.c.

1929 {
1930  FIXME("texture %p, src_texture %p, src_palette %p, flags %#x, channel %u, amplitude %.8e stub.\n",
1931  texture, src_texture, src_palette, flags, channel, amplitude);
1932 
1933  return D3D_OK;
1934 }
#define FIXME(fmt,...)
Definition: debug.h:111
GLenum GLuint texture
Definition: glext.h:6295
GLbitfield flags
Definition: glext.h:7161
#define D3D_OK
Definition: d3d.h:106

◆ D3DXCreateCubeTexture()

HRESULT WINAPI D3DXCreateCubeTexture ( struct IDirect3DDevice9 *  device,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DCubeTexture9 **  texture 
)

Definition at line 913 of file texture.c.

915 {
916  HRESULT hr;
917 
918  TRACE("(%p, %u, %u, %#x, %#x, %#x, %p)\n", device, size, miplevels, usage, format,
919  pool, texture);
920 
921  if (!device || !texture)
922  return D3DERR_INVALIDCALL;
923 
925 
926  if (FAILED(hr))
927  {
928  TRACE("D3DXCheckCubeTextureRequirements failed\n");
929  return hr;
930  }
931 
933 }
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:421
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define NULL
Definition: types.h:112
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1532

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx().

◆ D3DXCreateCubeTextureFromFileA()

HRESULT WINAPI D3DXCreateCubeTextureFromFileA ( IDirect3DDevice9 *  device,
const char src_filename,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1531 of file texture.c.

1534 {
1535  int len;
1536  HRESULT hr;
1537  WCHAR *filename;
1538  void *data;
1539  DWORD data_size;
1540 
1541  TRACE("(%p, %s, %p): relay\n", device, wine_dbgstr_a(src_filename), cube_texture);
1542 
1543  if (!src_filename) return D3DERR_INVALIDCALL;
1544 
1545  len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
1546  filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1547  if (!filename) return E_OUTOFMEMORY;
1548  MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
1549 
1550  hr = map_view_of_file(filename, &data, &data_size);
1551  if (FAILED(hr))
1552  {
1554  return D3DXERR_INVALIDDATA;
1555  }
1556 
1559 
1562  return hr;
1563 }
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:186
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
const char * filename
Definition: ioapi.h:135
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1400
#define UnmapViewOfFile
Definition: compat.h:605
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ D3DXCreateCubeTextureFromFileExA()

HRESULT WINAPI D3DXCreateCubeTextureFromFileExA ( IDirect3DDevice9 *  device,
const char src_filename,
UINT  size,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO image_info,
PALETTEENTRY palette,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1585 of file texture.c.

1598 {
1599  int len;
1600  HRESULT hr;
1601  WCHAR *filename;
1602  void *data;
1603  DWORD data_size;
1604 
1605  TRACE("(%p, %s, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1606  device, wine_dbgstr_a(src_filename), size, mip_levels, usage, format,
1607  pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1608 
1609  if (!src_filename) return D3DERR_INVALIDCALL;
1610 
1611  len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
1612  filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1613  if (!filename) return E_OUTOFMEMORY;
1614  MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
1615 
1616  hr = map_view_of_file(filename, &data, &data_size);
1617  if (FAILED(hr))
1618  {
1620  return D3DXERR_INVALIDDATA;
1621  }
1622 
1623  hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, data, data_size, size, mip_levels,
1624  usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1625 
1628  return hr;
1629 }
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:186
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
const char * filename
Definition: ioapi.h:135
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
static HPALETTE palette
Definition: clipboard.c:1345
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1400
#define UnmapViewOfFile
Definition: compat.h:605
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ D3DXCreateCubeTextureFromFileExW()

HRESULT WINAPI D3DXCreateCubeTextureFromFileExW ( IDirect3DDevice9 *  device,
const WCHAR src_filename,
UINT  size,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO image_info,
PALETTEENTRY palette,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1631 of file texture.c.

1644 {
1645  HRESULT hr;
1646  void *data;
1647  DWORD data_size;
1648 
1649  TRACE("(%p, %s, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1650  device, wine_dbgstr_w(src_filename), size, mip_levels, usage, format,
1651  pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1652 
1653  hr = map_view_of_file(src_filename, &data, &data_size);
1654  if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1655 
1656  hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, data, data_size, size, mip_levels,
1657  usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1658 
1660  return hr;
1661 }
HRESULT hr
Definition: shlfolder.c:183
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static HPALETTE palette
Definition: clipboard.c:1345
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1400
#define UnmapViewOfFile
Definition: compat.h:605
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ D3DXCreateCubeTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void data,
UINT  datasize,
struct IDirect3DCubeTexture9 **  texture 
)

Definition at line 935 of file texture.c.

937 {
938  TRACE("(%p, %p, %u, %p)\n", device, data, datasize, texture);
939 
942 }
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
static SIZE_T datasize
Definition: asm.c:30
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1400

Referenced by test_D3DXCreateCubeTextureFromFileInMemory().

◆ D3DXCreateCubeTextureFromFileInMemoryEx()

HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device,
const void src_data,
UINT  src_data_size,
UINT  size,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO src_info,
PALETTEENTRY palette,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1400 of file texture.c.

1414 {
1415  HRESULT hr;
1416  D3DCAPS9 caps;
1417  UINT loaded_miplevels;
1418  D3DXIMAGE_INFO img_info;
1419  BOOL dynamic_texture;
1420  BOOL file_size = FALSE;
1421  BOOL file_format = FALSE;
1422  BOOL file_mip_levels = FALSE;
1423  IDirect3DCubeTexture9 *tex, *buftex;
1424 
1425  TRACE("(%p, %p, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p)\n", device,
1426  src_data, src_data_size, size, mip_levels, usage, format, pool, filter, mip_filter,
1427  color_key, src_info, palette, cube_texture);
1428 
1429  if (!device || !cube_texture || !src_data || !src_data_size)
1430  return D3DERR_INVALIDCALL;
1431 
1432  hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &img_info);
1433  if (FAILED(hr))
1434  return hr;
1435 
1436  if (img_info.ImageFileFormat != D3DXIFF_DDS)
1437  return D3DXERR_INVALIDDATA;
1438 
1439  if (img_info.Width != img_info.Height)
1440  return D3DXERR_INVALIDDATA;
1441 
1442  if (size == 0 || size == D3DX_DEFAULT_NONPOW2)
1443  size = img_info.Width;
1444  if (size == D3DX_DEFAULT)
1445  size = make_pow2(img_info.Width);
1446 
1448  format = img_info.Format;
1449 
1450  if (size == D3DX_FROM_FILE)
1451  {
1452  file_size = TRUE;
1453  size = img_info.Width;
1454  }
1455 
1456  if (format == D3DFMT_FROM_FILE)
1457  {
1458  file_format = TRUE;
1459  format = img_info.Format;
1460  }
1461 
1462  if (mip_levels == D3DX_FROM_FILE)
1463  {
1464  file_mip_levels = TRUE;
1465  mip_levels = img_info.MipLevels;
1466  }
1467 
1469  if (FAILED(hr))
1470  return hr;
1471 
1472  if ((file_size && size != img_info.Width)
1473  || (file_format && format != img_info.Format)
1474  || (file_mip_levels && mip_levels != img_info.MipLevels))
1475  return D3DERR_NOTAVAILABLE;
1476 
1478  if (FAILED(hr))
1479  return D3DERR_INVALIDCALL;
1480 
1481  dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
1482  if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
1483  {
1484  hr = D3DXCreateCubeTexture(device, size, mip_levels, 0, format, D3DPOOL_SYSTEMMEM, &buftex);
1485  tex = buftex;
1486  }
1487  else
1488  {
1489  hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, pool, &tex);
1490  buftex = NULL;
1491  }
1492  if (FAILED(hr))
1493  return hr;
1494 
1495  hr = load_cube_texture_from_dds(tex, src_data, palette, filter, color_key, &img_info);
1496  if (FAILED(hr))
1497  {
1499  return hr;
1500  }
1501 
1502  loaded_miplevels = min(IDirect3DCubeTexture9_GetLevelCount(tex), img_info.MipLevels);
1503  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, palette, loaded_miplevels - 1, mip_filter);
1504  if (FAILED(hr))
1505  {
1507  return hr;
1508  }
1509 
1510  if (buftex)
1511  {
1512  hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, pool, &tex);
1513  if (FAILED(hr))
1514  {
1516  return hr;
1517  }
1518 
1519  IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)buftex, (IDirect3DBaseTexture9 *)tex);
1521  }
1522 
1523  if (src_info)
1524  *src_info = img_info;
1525 
1526  *cube_texture = tex;
1527  return D3D_OK;
1528 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:421
static unsigned int file_size
Definition: regtests2xml.c:47
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DCubeTexture9_GetLevelCount(p)
Definition: d3d9.h:932
#define TRUE
Definition: types.h:120
#define D3DFMT_FROM_FILE
Definition: d3dx9.h:28
#define D3DX_FROM_FILE
Definition: d3dx9.h:27
#define D3DERR_INVALIDCALL
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
UINT MipLevels
Definition: d3dx9tex.h:81
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define IDirect3DDevice9_UpdateTexture(p, a, b)
Definition: d3d9.h:1538
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:52
DWORD Caps2
Definition: d3d9caps.h:267
D3DXIMAGE_FILEFORMAT ImageFileFormat
Definition: d3dx9tex.h:84
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
D3DFORMAT Format
Definition: d3dx9tex.h:82
LONG HRESULT
Definition: typedefs.h:79
#define D3DX_DEFAULT_NONPOW2
Definition: d3dx9.h:25
HRESULT WINAPI D3DXCreateCubeTexture(struct IDirect3DDevice9 *device, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DCubeTexture9 **texture)
Definition: texture.c:913
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static uint32_t make_pow2(uint32_t num)
static HPALETTE palette
Definition: clipboard.c:1345
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:985
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define D3DCAPS2_DYNAMICTEXTURES
Definition: d3d8caps.h:25

Referenced by D3DXCreateCubeTextureFromFileA(), D3DXCreateCubeTextureFromFileExA(), D3DXCreateCubeTextureFromFileExW(), D3DXCreateCubeTextureFromFileInMemory(), D3DXCreateCubeTextureFromFileW(), and test_D3DXCreateCubeTextureFromFileInMemoryEx().

◆ D3DXCreateCubeTextureFromFileW()

HRESULT WINAPI D3DXCreateCubeTextureFromFileW ( IDirect3DDevice9 *  device,
const WCHAR src_filename,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1565 of file texture.c.

1568 {
1569  HRESULT hr;
1570  void *data;
1571  DWORD data_size;
1572 
1573  TRACE("(%p, %s, %p): relay\n", device, wine_dbgstr_w(src_filename), cube_texture);
1574 
1575  hr = map_view_of_file(src_filename, &data, &data_size);
1576  if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1577 
1580 
1582  return hr;
1583 }
HRESULT hr
Definition: shlfolder.c:183
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1400
#define UnmapViewOfFile
Definition: compat.h:605

◆ D3DXCreateTexture()

HRESULT WINAPI D3DXCreateTexture ( struct IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DTexture9 **  texture 
)

Definition at line 528 of file texture.c.

530 {
531  HRESULT hr;
532 
533  TRACE("device %p, width %u, height %u, miplevels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
534  device, width, height, miplevels, usage, format, pool, texture);
535 
536  if (!device || !texture)
537  return D3DERR_INVALIDCALL;
538 
540  return hr;
541 
543 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:412

Referenced by D3DXCreateTextureFromFileInMemoryEx(), test_D3DXCreateTexture(), test_effect_parameter_block(), and test_effect_setvalue_object().

◆ D3DXCreateTextureFromFileA()

HRESULT WINAPI D3DXCreateTextureFromFileA ( struct IDirect3DDevice9 *  device,
const char srcfile,
struct IDirect3DTexture9 **  texture 
)

Definition at line 818 of file texture.c.

820 {
821  TRACE("(%p, %s, %p)\n", device, debugstr_a(srcfile), texture);
822 
825 }
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint texture
Definition: glext.h:6295
HRESULT WINAPI D3DXCreateTextureFromFileExA(struct IDirect3DDevice9 *device, const char *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:789
#define NULL
Definition: types.h:112

◆ D3DXCreateTextureFromFileExA()

HRESULT WINAPI D3DXCreateTextureFromFileExA ( struct IDirect3DDevice9 *  device,
const char srcfile,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 789 of file texture.c.

793 {
794  WCHAR *widename;
795  HRESULT hr;
796  DWORD len;
797 
798  TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
799  "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
800  device, debugstr_a(srcfile), width, height, miplevels, usage, format,
801  pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
802 
803  if (!device || !srcfile || !texture)
804  return D3DERR_INVALIDCALL;
805 
806  len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
807  widename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*widename));
808  MultiByteToWideChar(CP_ACP, 0, srcfile, -1, widename, len);
809 
810  hr = D3DXCreateTextureFromFileExW(device, widename, width, height, miplevels,
811  usage, format, pool, filter, mipfilter,
812  colorkey, srcinfo, palette, texture);
813 
814  HeapFree(GetProcessHeap(), 0, widename);
815  return hr;
816 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
HRESULT WINAPI D3DXCreateTextureFromFileExW(struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:757
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by D3DXCreateTextureFromFileA().

◆ D3DXCreateTextureFromFileExW()

HRESULT WINAPI D3DXCreateTextureFromFileExW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 757 of file texture.c.

761 {
762  void *buffer;
763  HRESULT hr;
764  DWORD size;
765 
766  TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
767  "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
768  device, debugstr_w(srcfile), width, height, miplevels, usage, format,
769  pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
770 
771  if (!srcfile)
772  return D3DERR_INVALIDCALL;
773 
774  hr = map_view_of_file(srcfile, &buffer, &size);
775  if (FAILED(hr))
776  {
777  WARN("Failed to open file.\n");
778  return D3DXERR_INVALIDDATA;
779  }
780 
782  filter, mipfilter, colorkey, srcinfo, palette, texture);
783 
785 
786  return hr;
787 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:568
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define UnmapViewOfFile
Definition: compat.h:605
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by D3DXCreateTextureFromFileExA(), and D3DXCreateTextureFromFileW().

◆ D3DXCreateTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
struct IDirect3DTexture9 **  texture 
)

Definition at line 748 of file texture.c.

750 {
751  TRACE("(%p, %p, %d, %p)\n", device, srcdata, srcdatasize, texture);
752 
755 }
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:568
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define NULL
Definition: types.h:112

Referenced by test_D3DXCreateTextureFromFileInMemory().

◆ D3DXCreateTextureFromFileInMemoryEx()

HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 568 of file texture.c.

572 {
573  BOOL dynamic_texture, format_specified = FALSE;
574  unsigned int loaded_miplevels, skip_levels;
575  IDirect3DSurface9 *surface;
576  IDirect3DTexture9 **texptr;
577  IDirect3DTexture9 *buftex;
578  D3DXIMAGE_INFO imginfo;
579  D3DCAPS9 caps;
580  HRESULT hr;
581 
582  TRACE("device %p, srcdata %p, srcdatasize %u, width %u, height %u, miplevels %u,"
583  " usage %#x, format %#x, pool %#x, filter %#x, mipfilter %#x, colorkey %#x,"
584  " srcinfo %p, palette %p, texture %p.\n",
585  device, srcdata, srcdatasize, width, height, miplevels, usage, format, pool,
586  filter, mipfilter, colorkey, srcinfo, palette, texture);
587 
588  /* check for invalid parameters */
589  if (!device || !texture || !srcdata || !srcdatasize)
590  return D3DERR_INVALIDCALL;
591 
592  hr = D3DXGetImageInfoFromFileInMemory(srcdata, srcdatasize, &imginfo);
593  if (FAILED(hr))
594  {
595  FIXME("Unrecognized file format, returning failure.\n");
596  *texture = NULL;
597  return hr;
598  }
599 
600  /* handle default values */
601  if (width == 0 || width == D3DX_DEFAULT_NONPOW2)
602  width = imginfo.Width;
603 
604  if (height == 0 || height == D3DX_DEFAULT_NONPOW2)
605  height = imginfo.Height;
606 
607  if (width == D3DX_DEFAULT)
608  width = make_pow2(imginfo.Width);
609 
610  if (height == D3DX_DEFAULT)
611  height = make_pow2(imginfo.Height);
612 
614  format = imginfo.Format;
615  else
616  format_specified = TRUE;
617 
618  if (width == D3DX_FROM_FILE)
619  {
620  width = imginfo.Width;
621  }
622 
623  if (height == D3DX_FROM_FILE)
624  {
625  height = imginfo.Height;
626  }
627 
628  if (format == D3DFMT_FROM_FILE)
629  {
630  format = imginfo.Format;
631  }
632 
633  if (miplevels == D3DX_FROM_FILE)
634  {
635  miplevels = imginfo.MipLevels;
636  }
637 
638  skip_levels = mipfilter != D3DX_DEFAULT ? mipfilter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0;
639  if (skip_levels && imginfo.MipLevels > skip_levels)
640  {
641  TRACE("Skipping the first %u (of %u) levels of a DDS mipmapped texture.\n",
642  skip_levels, imginfo.MipLevels);
643  TRACE("Texture level 0 dimensions are %ux%u.\n", imginfo.Width, imginfo.Height);
644  width >>= skip_levels;
645  height >>= skip_levels;
646  miplevels -= skip_levels;
647  }
648  else
649  {
650  skip_levels = 0;
651  }
652 
653  /* Fix up texture creation parameters. */
655  if (FAILED(hr))
656  {
657  FIXME("Couldn't find suitable texture parameters.\n");
658  *texture = NULL;
659  return hr;
660  }
661 
662  if (colorkey && !format_specified)
664 
665  if (imginfo.ResourceType == D3DRTYPE_VOLUMETEXTURE
666  && D3DFMT_DXT1 <= imginfo.Format && imginfo.Format <= D3DFMT_DXT5 && miplevels > 1)
667  {
668  FIXME("Generation of mipmaps for compressed volume textures is not implemented yet.\n");
669  miplevels = 1;
670  }
671 
673  return D3DERR_INVALIDCALL;
674 
675  /* Create the to-be-filled texture */
676  dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
677  if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
678  {
679  hr = D3DXCreateTexture(device, width, height, miplevels, 0, format, D3DPOOL_SYSTEMMEM, &buftex);
680  texptr = &buftex;
681  }
682  else
683  {
685  texptr = texture;
686  }
687 
688  if (FAILED(hr))
689  {
690  FIXME("Texture creation failed.\n");
691  *texture = NULL;
692  return hr;
693  }
694 
695  TRACE("Texture created correctly. Now loading the texture data into it.\n");
696  if (imginfo.ImageFileFormat != D3DXIFF_DDS)
697  {
698  IDirect3DTexture9_GetSurfaceLevel(*texptr, 0, &surface);
699  hr = D3DXLoadSurfaceFromFileInMemory(surface, palette, NULL, srcdata, srcdatasize, NULL, filter, colorkey, NULL);
700  IDirect3DSurface9_Release(surface);
701  loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(*texptr), imginfo.MipLevels);
702  }
703  else
704  {
705  hr = load_texture_from_dds(*texptr, srcdata, palette, filter, colorkey, &imginfo, skip_levels,
706  &loaded_miplevels);
707  }
708 
709  if (FAILED(hr))
710  {
711  FIXME("Texture loading failed.\n");
712  IDirect3DTexture9_Release(*texptr);
713  *texture = NULL;
714  return hr;
715  }
716 
717  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) *texptr, palette, loaded_miplevels - 1, mipfilter);
718  if (FAILED(hr))
719  {
720  FIXME("Texture filtering failed.\n");
721  IDirect3DTexture9_Release(*texptr);
722  *texture = NULL;
723  return hr;
724  }
725 
726  /* Move the data to the actual texture if necessary */
727  if (texptr == &buftex)
728  {
730 
731  if (FAILED(hr))
732  {
734  *texture = NULL;
735  return hr;
736  }
737 
738  IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9*)buftex, (IDirect3DBaseTexture9*)(*texture));
740  }
741 
742  if (srcinfo)
743  *srcinfo = imginfo;
744 
745  return D3D_OK;
746 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
Definition: texture.c:528
#define D3DFMT_FROM_FILE
Definition: d3dx9.h:28
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
#define D3DX_FROM_FILE
Definition: d3dx9.h:27
#define D3DERR_INVALIDCALL
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
static D3DFORMAT get_alpha_replacement_format(D3DFORMAT format)
Definition: texture.c:545
D3DRESOURCETYPE ResourceType
Definition: d3dx9tex.h:83
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
UINT MipLevels
Definition: d3dx9tex.h:81
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define IDirect3DDevice9_UpdateTexture(p, a, b)
Definition: d3d9.h:1538
#define FIXME(fmt,...)
Definition: debug.h:111
#define D3DX_DEFAULT
Definition: d3dx9.h:24
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:52
DWORD Caps2
Definition: d3d9caps.h:267
#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT
Definition: d3dx9tex.h:43
D3DXIMAGE_FILEFORMAT ImageFileFormat
Definition: d3dx9tex.h:84
#define TRACE(s)
Definition: solgame.cpp:4
D3DFORMAT Format
Definition: d3dx9tex.h:82
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
#define D3DX_DEFAULT_NONPOW2
Definition: d3dx9.h:25
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static uint32_t make_pow2(uint32_t num)
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:412
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:985
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, const PALETTEENTRY *pDestPalette, const RECT *pDestRect, const void *pSrcData, UINT SrcDataSize, const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
Definition: surface.c:1245
HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels, unsigned int *loaded_miplevels) DECLSPEC_HIDDEN
Definition: surface.c:737
#define D3DCAPS2_DYNAMICTEXTURES
Definition: d3d8caps.h:25

Referenced by D3DXCreateTextureFromFileExW(), D3DXCreateTextureFromFileInMemory(), D3DXCreateTextureFromResourceExA(), D3DXCreateTextureFromResourceExW(), and test_D3DXCreateTextureFromFileInMemoryEx().

◆ D3DXCreateTextureFromFileW()

HRESULT WINAPI D3DXCreateTextureFromFileW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
struct IDirect3DTexture9 **  texture 
)

Definition at line 827 of file texture.c.

829 {
830  TRACE("(%p, %s, %p)\n", device, debugstr_w(srcfile), texture);
831 
834 }
Definition: devices.h:37
#define debugstr_w
Definition: kernel32.h:32
#define D3DX_DEFAULT
Definition: d3dx9.h:24
HRESULT WINAPI D3DXCreateTextureFromFileExW(struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:757
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define NULL
Definition: types.h:112

◆ D3DXCreateTextureFromResourceA()

HRESULT WINAPI D3DXCreateTextureFromResourceA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
struct IDirect3DTexture9 **  texture 
)

Definition at line 837 of file texture.c.

839 {
840  TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(resource));
841 
844 }
HRESULT WINAPI D3DXCreateTextureFromResourceExA(struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:855
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint texture
Definition: glext.h:6295
#define NULL
Definition: types.h:112

Referenced by test_D3DXCreateTexture().

◆ D3DXCreateTextureFromResourceExA()

HRESULT WINAPI D3DXCreateTextureFromResourceExA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 855 of file texture.c.

859 {
860  HRSRC resinfo;
861  void *buffer;
862  DWORD size;
863 
864  TRACE("device %p, srcmodule %p, resource %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
865  "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
866  device, srcmodule, debugstr_a(resource), width, height, miplevels, usage, format,
867  pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
868 
869  if (!device || !texture)
870  return D3DERR_INVALIDCALL;
871 
872  if (!(resinfo = FindResourceA(srcmodule, resource, (const char *)RT_RCDATA))
873  /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
874  && !(resinfo = FindResourceA(srcmodule, resource, (const char *)RT_BITMAP)))
875  return D3DXERR_INVALIDDATA;
876 
877  if (FAILED(load_resource_into_memory(srcmodule, resinfo, &buffer, &size)))
878  return D3DXERR_INVALIDDATA;
879 
881  usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
882 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:568
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:170
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_RCDATA
Definition: pedump.c:372
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define RT_BITMAP
Definition: pedump.c:364
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by D3DXCreateTextureFromResourceA(), and test_D3DXCreateTexture().

◆ D3DXCreateTextureFromResourceExW()

HRESULT WINAPI D3DXCreateTextureFromResourceExW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 884 of file texture.c.

888 {
889  HRSRC resinfo;
890  void *buffer;
891  DWORD size;
892 
893  TRACE("device %p, srcmodule %p, resource %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
894  "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
895  device, srcmodule, debugstr_w(resource), width, height, miplevels, usage, format,
896  pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
897 
898  if (!device || !texture)
899  return D3DERR_INVALIDCALL;
900 
901  if (!(resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_RCDATA))
902  /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
903  && !(resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_BITMAP)))
904  return D3DXERR_INVALIDDATA;
905 
906  if (FAILED(load_resource_into_memory(srcmodule, resinfo, &buffer, &size)))
907  return D3DXERR_INVALIDDATA;
908 
910  usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
911 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:568
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define debugstr_w
Definition: kernel32.h:32
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:170
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_RCDATA
Definition: pedump.c:372
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define RT_BITMAP
Definition: pedump.c:364
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by D3DXCreateTextureFromResourceW().

◆ D3DXCreateTextureFromResourceW()

HRESULT WINAPI D3DXCreateTextureFromResourceW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
struct IDirect3DTexture9 **  texture 
)

Definition at line 846 of file texture.c.

848 {
849  TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(resource));
850 
853 }
Definition: devices.h:37
#define debugstr_w
Definition: kernel32.h:32
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXCreateTextureFromResourceExW(struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:884

◆ D3DXCreateVolumeTexture()

HRESULT WINAPI D3DXCreateVolumeTexture ( struct IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DVolumeTexture9 **  texture 
)

Definition at line 944 of file texture.c.

946 {
947  HRESULT hr;
948 
949  TRACE("(%p, %u, %u, %u, %u, %#x, %#x, %#x, %p)\n", device, width, height, depth,
950  miplevels, usage, format, pool, texture);
951 
952  if (!device || !texture)
953  return D3DERR_INVALIDCALL;
954 
956  &miplevels, usage, &format, pool);
957 
958  if (FAILED(hr))
959  {
960  TRACE("D3DXCheckVolumeTextureRequirements failed\n");
961  return hr;
962  }
963 
966 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1531
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:456
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define NULL
Definition: types.h:112

Referenced by D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCreateVolumeTextureFromFileA()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileA ( IDirect3DDevice9 *  device,
const char filename,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 968 of file texture.c.

971 {
972  int len;
973  HRESULT hr;
974  void *data;
975  DWORD data_size;
976  WCHAR *filenameW;
977 
978  TRACE("(%p, %s, %p): relay\n",
979  device, debugstr_a(filename), volume_texture);
980 
981  if (!filename) return D3DERR_INVALIDCALL;
982 
983  len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
984  filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
985  if (!filenameW) return E_OUTOFMEMORY;
987 
988  hr = map_view_of_file(filenameW, &data, &data_size);
990  if (FAILED(hr)) return D3DXERR_INVALIDDATA;
991 
994 
996  return hr;
997 }
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
const char * filename
Definition: ioapi.h:135
static const WCHAR filenameW[]
Definition: amstream.c:41
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLenum GLsizei len
Definition: glext.h:6722
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define UnmapViewOfFile
Definition: compat.h:605
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ D3DXCreateVolumeTextureFromFileExA()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA ( IDirect3DDevice9 *  device,
const char filename,
UINT  width,
UINT  height,
UINT  depth,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO src_info,
PALETTEENTRY palette,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1022 of file texture.c.

1037 {
1038  int len;
1039  HRESULT hr;
1040  WCHAR *filenameW;
1041  void *data;
1042  DWORD data_size;
1043 
1044  TRACE("(%p, %s, %u, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1045  device, debugstr_a(filename), width, height, depth, mip_levels,
1046  usage, format, pool, filter, mip_filter, color_key, src_info,
1047  palette, volume_texture);
1048 
1049  if (!filename) return D3DERR_INVALIDCALL;
1050 
1051  len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
1052  filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1053  if (!filenameW) return E_OUTOFMEMORY;
1055 
1056  hr = map_view_of_file(filenameW, &data, &data_size);
1058  if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1059 
1061  mip_levels, usage, format, pool, filter, mip_filter, color_key, src_info, palette,
1062  volume_texture);
1063 
1065  return hr;
1066 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
const char * filename
Definition: ioapi.h:135
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static const WCHAR filenameW[]
Definition: amstream.c:41
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define UnmapViewOfFile
Definition: compat.h:605
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ D3DXCreateVolumeTextureFromFileExW()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileExW ( IDirect3DDevice9 *  device,
const WCHAR filename,
UINT  width,
UINT  height,
UINT  depth,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO src_info,
PALETTEENTRY palette,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1068 of file texture.c.

1083 {
1084  HRESULT hr;
1085  void *data;
1086  DWORD data_size;
1087 
1088  TRACE("(%p, %s, %u, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1089  device, debugstr_w(filename), width, height, depth, mip_levels,
1090  usage, format, pool, filter, mip_filter, color_key, src_info,
1091  palette, volume_texture);
1092 
1093  if (!filename) return D3DERR_INVALIDCALL;
1094 
1095  hr = map_view_of_file(filename, &data, &data_size);
1096  if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1097 
1099  mip_levels, usage, format, pool, filter, mip_filter, color_key, src_info, palette,
1100  volume_texture);
1101 
1103  return hr;
1104 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
const char * filename
Definition: ioapi.h:135
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
#define UnmapViewOfFile
Definition: compat.h:605
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ D3DXCreateVolumeTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory ( IDirect3DDevice9 *  device,
const void data,
UINT  data_size,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1106 of file texture.c.

1110 {
1111  TRACE("(%p, %p, %u, %p): relay\n", device, data, data_size, volume_texture);
1112 
1115  0, NULL, NULL, volume_texture);
1116 }
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
#define NULL
Definition: types.h:112

Referenced by test_D3DXCreateVolumeTextureFromFileInMemory().

◆ D3DXCreateVolumeTextureFromFileInMemoryEx()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device,
const void data,
UINT  data_size,
UINT  width,
UINT  height,
UINT  depth,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO info,
PALETTEENTRY palette,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1118 of file texture.c.

1134 {
1135  HRESULT hr;
1136  D3DCAPS9 caps;
1137  D3DXIMAGE_INFO image_info;
1138  BOOL dynamic_texture;
1139  BOOL file_width = FALSE;
1140  BOOL file_height = FALSE;
1141  BOOL file_depth = FALSE;
1142  BOOL file_format = FALSE;
1143  BOOL file_mip_levels = FALSE;
1144  IDirect3DVolumeTexture9 *tex, *buftex;
1145 
1146  TRACE("(%p, %p, %u, %u, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p)\n",
1147  device, data, data_size, width, height, depth, mip_levels, usage, format, pool,
1148  filter, mip_filter, color_key, info, palette, volume_texture);
1149 
1150  if (!device || !data || !data_size || !volume_texture)
1151  return D3DERR_INVALIDCALL;
1152 
1153  hr = D3DXGetImageInfoFromFileInMemory(data, data_size, &image_info);
1154  if (FAILED(hr)) return hr;
1155 
1156  if (image_info.ImageFileFormat != D3DXIFF_DDS)
1157  return D3DXERR_INVALIDDATA;
1158 
1159  if (width == 0 || width == D3DX_DEFAULT_NONPOW2)
1160  width = image_info.Width;
1161  if (width == D3DX_DEFAULT)
1162  width = make_pow2(image_info.Width);
1163 
1164  if (height == 0 || height == D3DX_DEFAULT_NONPOW2)
1165  height = image_info.Height;
1166  if (height == D3DX_DEFAULT)
1167  height = make_pow2(image_info.Height);
1168 
1169  if (depth == 0 || depth == D3DX_DEFAULT_NONPOW2)
1170  depth = image_info.Depth;
1171  if (depth == D3DX_DEFAULT)
1172  depth = make_pow2(image_info.Depth);
1173 
1175  format = image_info.Format;
1176 
1177  if (width == D3DX_FROM_FILE)
1178  {
1179  file_width = TRUE;
1180  width = image_info.Width;
1181  }
1182 
1183  if (height == D3DX_FROM_FILE)
1184  {
1185  file_height = TRUE;
1186  height = image_info.Height;
1187  }
1188 
1189  if (depth == D3DX_FROM_FILE)
1190  {
1191  file_depth = TRUE;
1192  depth = image_info.Depth;
1193  }
1194 
1195  if (format == D3DFMT_FROM_FILE)
1196  {
1197  file_format = TRUE;
1198  format = image_info.Format;
1199  }
1200 
1201  if (mip_levels == D3DX_FROM_FILE)
1202  {
1203  file_mip_levels = TRUE;
1204  mip_levels = image_info.MipLevels;
1205  }
1206 
1208  if (FAILED(hr)) return hr;
1209 
1210  if ((file_width && width != image_info.Width)
1211  || (file_height && height != image_info.Height)
1212  || (file_depth && depth != image_info.Depth)
1213  || (file_format && format != image_info.Format)
1214  || (file_mip_levels && mip_levels != image_info.MipLevels))
1215  return D3DERR_NOTAVAILABLE;
1216 
1218  if (FAILED(hr))
1219  return D3DERR_INVALIDCALL;
1220 
1221  if (mip_levels > image_info.MipLevels)
1222  {
1223  FIXME("Generation of mipmaps for volume textures is not implemented yet.\n");
1224  mip_levels = image_info.MipLevels;
1225  }
1226 
1227  dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
1228  if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
1229  {
1230  hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, 0, format, D3DPOOL_SYSTEMMEM, &buftex);
1231  tex = buftex;
1232  }
1233  else
1234  {
1235  hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex);
1236  buftex = NULL;
1237  }
1238  if (FAILED(hr)) return hr;
1239 
1240  hr = load_volume_texture_from_dds(tex, data, palette, filter, color_key, &image_info);
1241  if (FAILED(hr))
1242  {
1244  return hr;
1245  }
1246 
1247  if (buftex)
1248  {
1249  hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex);
1250  if (FAILED(hr))
1251  {
1253  return hr;
1254  }
1255 
1256  IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)buftex, (IDirect3DBaseTexture9 *)tex);
1258  }
1259 
1260  if (info)
1261  *info = image_info;
1262 
1263  *volume_texture = tex;
1264  return D3D_OK;
1265 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define D3DFMT_FROM_FILE
Definition: d3dx9.h:28
#define D3DX_FROM_FILE
Definition: d3dx9.h:27
#define D3DERR_INVALIDCALL
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
UINT MipLevels
Definition: d3dx9tex.h:81
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define IDirect3DDevice9_UpdateTexture(p, a, b)
Definition: d3d9.h:1538
#define FIXME(fmt,...)
Definition: debug.h:111
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
DWORD Caps2
Definition: d3d9caps.h:267
D3DXIMAGE_FILEFORMAT ImageFileFormat
Definition: d3dx9tex.h:84
#define TRACE(s)
Definition: solgame.cpp:4
D3DFORMAT Format
Definition: d3dx9tex.h:82
LONG HRESULT
Definition: typedefs.h:79
#define D3DX_DEFAULT_NONPOW2
Definition: d3dx9.h:25
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
HRESULT WINAPI D3DXCreateVolumeTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DVolumeTexture9 **texture)
Definition: texture.c:944
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
Definition: surface.c:847
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:456
static uint32_t make_pow2(uint32_t num)
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:985
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define D3DCAPS2_DYNAMICTEXTURES
Definition: d3d8caps.h:25

Referenced by D3DXCreateVolumeTextureFromFileA(), D3DXCreateVolumeTextureFromFileExA(), D3DXCreateVolumeTextureFromFileExW(), D3DXCreateVolumeTextureFromFileInMemory(), D3DXCreateVolumeTextureFromFileW(), and test_D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCreateVolumeTextureFromFileW()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileW ( IDirect3DDevice9 *  device,
const WCHAR filename,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 999 of file texture.c.

1002 {
1003  HRESULT hr;
1004  void *data;
1005  DWORD data_size;
1006 
1007  TRACE("(%p, %s, %p): relay\n",
1008  device, debugstr_w(filename), volume_texture);
1009 
1010  if (!filename) return D3DERR_INVALIDCALL;
1011 
1012  hr = map_view_of_file(filename, &data, &data_size);
1013  if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1014 
1017 
1019  return hr;
1020 }
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
const char * filename
Definition: ioapi.h:135
Definition: devices.h:37
#define debugstr_w
Definition: kernel32.h:32
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
#define NULL
Definition: types.h:112
#define UnmapViewOfFile
Definition: compat.h:605

◆ D3DXFillCubeTexture()

HRESULT WINAPI D3DXFillCubeTexture ( struct IDirect3DCubeTexture9 *  texture,
LPD3DXFILL3D  function,
void funcdata 
)

Definition at line 1695 of file texture.c.

1696 {
1697  DWORD miplevels;
1698  DWORD m, x, y, f;
1700  D3DLOCKED_RECT lock_rect;
1703  const struct pixel_format_desc *format;
1704  BYTE *data;
1705  static const enum cube_coord coordmap[6][3] =
1706  {
1707  {ONE, YCOORDINV, XCOORDINV},
1708  {ZERO, YCOORDINV, XCOORD},
1709  {XCOORD, ONE, YCOORD},
1710  {XCOORD, ZERO, YCOORDINV},
1711  {XCOORD, YCOORDINV, ONE},
1713  };
1714 
1715  if (texture == NULL || function == NULL)
1716  return D3DERR_INVALIDCALL;
1717 
1719 
1720  for (m = 0; m < miplevels; m++)
1721  {
1723  return D3DERR_INVALIDCALL;
1724 
1725  format = get_format_info(desc.Format);
1726  if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF)
1727  {
1728  FIXME("Unsupported texture format %#x\n", desc.Format);
1729  return D3DERR_INVALIDCALL;
1730  }
1731 
1732  for (f = 0; f < 6; f++)
1733  {
1735  return D3DERR_INVALIDCALL;
1736 
1737  size.x = (f == 0) || (f == 1) ? 0.0f : 2.0f / desc.Width;
1738  size.y = (f == 2) || (f == 3) ? 0.0f : 2.0f / desc.Width;
1739  size.z = (f == 4) || (f == 5) ? 0.0f : 2.0f / desc.Width;
1740 
1741  data = lock_rect.pBits;
1742 
1743  for (y = 0; y < desc.Height; y++)
1744  {
1745  for (x = 0; x < desc.Width; x++)
1746  {
1747  coord.x = get_cube_coord(coordmap[f][0], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1748  coord.y = get_cube_coord(coordmap[f][1], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1749  coord.z = get_cube_coord(coordmap[f][2], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1750 
1751  function(&value, &coord, &size, funcdata);
1752 
1753  fill_texture(format, data + y * lock_rect.Pitch + x * format->bytes_per_pixel, &value);
1754  }
1755  }
1757  }
1758  }
1759 
1760  return D3D_OK;
1761 }
Definition: pdh_main.c:93
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:937
Definition: texture.c:1670
static float get_cube_coord(enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
Definition: texture.c:1673
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
#define D3DERR_INVALIDCALL
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
Definition: texture.c:1669
const GLfloat * m
Definition: glext.h:10848
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLuint coord
Definition: glext.h:9511
#define IDirect3DCubeTexture9_LockRect(p, a, b, c, d, e)
Definition: d3d9.h:939
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:111
cube_coord
Definition: texture.c:1663
GLfloat f
Definition: glext.h:7540
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned char BYTE
Definition: xxhash.c:193
#define D3D_OK
Definition: d3d.h:106
#define f
Definition: ke_i.h:83
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDirect3DCubeTexture9_UnlockRect(p, a, b)
Definition: d3d9.h:940
static void fill_texture(const struct pixel_format_desc *format, BYTE *pos, const D3DXVECTOR4 *value)
Definition: texture.c:1267
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848

Referenced by test_D3DXFillCubeTexture(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXFillCubeTextureTX()

HRESULT WINAPI D3DXFillCubeTextureTX ( struct IDirect3DCubeTexture9 *  texture,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1763 of file texture.c.

1764 {
1765  FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1766  return E_NOTIMPL;
1767 }
#define FIXME(fmt,...)
Definition: debug.h:111
GLenum GLuint texture
Definition: glext.h:6295
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by test_texture_shader().

◆ D3DXFillTexture()

HRESULT WINAPI D3DXFillTexture ( struct IDirect3DTexture9 *  texture,
LPD3DXFILL2D  function,
void funcdata 
)

Definition at line 1323 of file texture.c.

1324 {
1325  IDirect3DSurface9 *surface, *temp_surface;
1326  DWORD miplevels;
1327  DWORD m, x, y;
1329  D3DLOCKED_RECT lock_rect;
1332  const struct pixel_format_desc *format;
1333  BYTE *data;
1334  HRESULT hr;
1335 
1336  TRACE("texture %p, function %p, funcdata %p.\n", texture, function, funcdata);
1337 
1338  if (!texture || !function)
1339  return D3DERR_INVALIDCALL;
1340 
1342 
1343  for (m = 0; m < miplevels; m++)
1344  {
1346  return hr;
1347 
1348  format = get_format_info(desc.Format);
1349  if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF)
1350  {
1351  FIXME("Unsupported texture format %#x.\n", desc.Format);
1352  return D3DERR_INVALIDCALL;
1353  }
1354 
1356  return hr;
1357  if (FAILED(hr = lock_surface(surface, NULL, &lock_rect, &temp_surface, TRUE)))
1358  {
1359  IDirect3DSurface9_Release(surface);
1360  return hr;
1361  }
1362 
1363  size.x = 1.0f / desc.Width;
1364  size.y = 1.0f / desc.Height;
1365 
1366  data = lock_rect.pBits;
1367 
1368  for (y = 0; y < desc.Height; y++)
1369  {
1370  /* The callback function expects the coordinates of the center
1371  of the texel */
1372  coord.y = (y + 0.5f) / desc.Height;
1373 
1374  for (x = 0; x < desc.Width; x++)
1375  {
1376  coord.x = (x + 0.5f) / desc.Width;
1377 
1378  function(&value, &coord, &size, funcdata);
1379 
1380  fill_texture(format, data + y * lock_rect.Pitch + x * format->bytes_per_pixel, &value);
1381  }
1382  }
1383  if (FAILED(hr = unlock_surface(surface, NULL, temp_surface, TRUE)))
1384  {
1385  IDirect3DSurface9_Release(surface);
1386  return hr;
1387  }
1388  IDirect3DSurface9_Release(surface);
1389  }
1390 
1391  return D3D_OK;
1392 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
#define D3DERR_INVALIDCALL
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLfloat * m
Definition: glext.h:10848
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
GLuint coord
Definition: glext.h:9511
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned char BYTE
Definition: xxhash.c:193
#define D3D_OK
Definition: d3d.h:106
HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN
Definition: surface.c:267
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void fill_texture(const struct pixel_format_desc *format, BYTE *pos, const D3DXVECTOR4 *value)
Definition: texture.c:1267
HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN
Definition: surface.c:209
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848

Referenced by test_D3DXFillTexture().

◆ D3DXFillTextureTX()

HRESULT WINAPI D3DXFillTextureTX ( struct IDirect3DTexture9 *  texture,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1394 of file texture.c.

1395 {
1396  FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1397  return E_NOTIMPL;
1398 }
#define FIXME(fmt,...)
Definition: debug.h:111
GLenum GLuint texture
Definition: glext.h:6295
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by test_texture_shader().

◆ D3DXFillVolumeTexture()

HRESULT WINAPI D3DXFillVolumeTexture ( struct IDirect3DVolumeTexture9 *  texture,
LPD3DXFILL3D  function,
void funcdata 
)

Definition at line 1769 of file texture.c.

1770 {
1771  DWORD miplevels;
1772  DWORD m, x, y, z;
1774  D3DLOCKED_BOX lock_box;
1777  const struct pixel_format_desc *format;
1778  BYTE *data;
1779 
1780  if (texture == NULL || function == NULL)
1781  return D3DERR_INVALIDCALL;
1782 
1784 
1785  for (m = 0; m < miplevels; m++)
1786  {
1788  return D3DERR_INVALIDCALL;
1789 
1790  format = get_format_info(desc.Format);
1791  if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF)
1792  {
1793  FIXME("Unsupported texture format %#x\n", desc.Format);
1794  return D3DERR_INVALIDCALL;
1795  }
1796 
1798  return D3DERR_INVALIDCALL;
1799 
1800  size.x = 1.0f / desc.Width;
1801  size.y = 1.0f / desc.Height;
1802  size.z = 1.0f / desc.Depth;
1803 
1804  data = lock_box.pBits;
1805 
1806  for (z = 0; z < desc.Depth; z++)
1807  {
1808  /* The callback function expects the coordinates of the center
1809  of the texel */
1810  coord.z = (z + 0.5f) / desc.Depth;
1811 
1812  for (y = 0; y < desc.Height; y++)
1813  {
1814  coord.y = (y + 0.5f) / desc.Height;
1815 
1816  for (x = 0; x < desc.Width; x++)
1817  {
1818  coord.x = (x + 0.5f) / desc.Width;
1819 
1820  function(&value, &coord, &size, funcdata);
1821 
1822  fill_texture(format, data + z * lock_box.SlicePitch + y * lock_box.RowPitch
1823  + x * format->bytes_per_pixel, &value);
1824  }
1825  }
1826  }
1828  }
1829 
1830  return D3D_OK;
1831 }
Definition: pdh_main.c:93
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1127
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
#define D3DERR_INVALIDCALL
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLfloat * m
Definition: glext.h:10848
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define IDirect3DVolumeTexture9_UnlockBox(p, a)
Definition: d3d9.h:1130
GLuint coord
Definition: glext.h:9511
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:111
GLdouble GLdouble z
Definition: glext.h:5874
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned char BYTE
Definition: xxhash.c:193
#define IDirect3DVolumeTexture9_LockBox(p, a, b, c, d)
Definition: d3d9.h:1129
#define D3D_OK
Definition: d3d.h:106
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void fill_texture(const struct pixel_format_desc *format, BYTE *pos, const D3DXVECTOR4 *value)
Definition: texture.c:1267
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848

Referenced by test_D3DXFillVolumeTexture().

◆ D3DXFillVolumeTextureTX()

HRESULT WINAPI D3DXFillVolumeTextureTX ( struct IDirect3DVolumeTexture9 *  texture,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1833 of file texture.c.

1834 {
1835  FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1836  return E_NOTIMPL;
1837 }
#define FIXME(fmt,...)
Definition: debug.h:111
GLenum GLuint texture
Definition: glext.h:6295
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by test_texture_shader().

◆ D3DXFilterTexture()

HRESULT WINAPI D3DXFilterTexture ( IDirect3DBaseTexture9 *  texture,
const PALETTEENTRY palette,
UINT  srclevel,
DWORD  filter 
)

Definition at line 52 of file texture.c.

56 {
57  UINT level;
58  HRESULT hr;
60 
61  TRACE("(%p, %p, %u, %#x)\n", texture, palette, srclevel, filter);
62 
63  if (!texture)
64  return D3DERR_INVALIDCALL;
65 
66  if ((filter & 0xFFFF) > D3DX_FILTER_BOX && filter != D3DX_DEFAULT)
67  return D3DERR_INVALIDCALL;
68 
69  if (srclevel == D3DX_DEFAULT)
70  srclevel = 0;
71  else if (srclevel >= IDirect3DBaseTexture9_GetLevelCount(texture))
72  return D3DERR_INVALIDCALL;
73 
75  {
76  case D3DRTYPE_TEXTURE:
78  {
79  IDirect3DSurface9 *topsurf, *mipsurf;
81  int i, numfaces;
82 
83  if (type == D3DRTYPE_TEXTURE)
84  {
85  numfaces = 1;
86  IDirect3DTexture9_GetLevelDesc((IDirect3DTexture9*) texture, srclevel, &desc);
87  }
88  else
89  {
90  numfaces = 6;
91  IDirect3DCubeTexture9_GetLevelDesc((IDirect3DTexture9*) texture, srclevel, &desc);
92  }
93 
94  if (filter == D3DX_DEFAULT)
95  {
96  if (is_pow2(desc.Width) && is_pow2(desc.Height))
98  else
100  }
101 
102  for (i = 0; i < numfaces; i++)
103  {
104  level = srclevel + 1;
105  hr = get_surface(type, texture, i, srclevel, &topsurf);
106 
107  if (FAILED(hr))
108  return D3DERR_INVALIDCALL;
109 
110  while (get_surface(type, texture, i, level, &mipsurf) == D3D_OK)
111  {
112  hr = D3DXLoadSurfaceFromSurface(mipsurf, palette, NULL, topsurf, palette, NULL, filter, 0);
113  IDirect3DSurface9_Release(topsurf);
114  topsurf = mipsurf;
115 
116  if (FAILED(hr))
117  break;
118 
119  level++;
120  }
121 
122  IDirect3DSurface9_Release(topsurf);
123  if (FAILED(hr))
124  return hr;
125  }
126 
127  return D3D_OK;
128  }
129 
131  {
133  int level, level_count;
134  IDirect3DVolume9 *top_volume, *mip_volume;
135  IDirect3DVolumeTexture9 *volume_texture = (IDirect3DVolumeTexture9*) texture;
136 
137  IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, srclevel, &desc);
138 
139  if (filter == D3DX_DEFAULT)
140  {
141  if (is_pow2(desc.Width) && is_pow2(desc.Height) && is_pow2(desc.Depth))
143  else
145  }
146 
147  hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, srclevel, &top_volume);
148  if (FAILED(hr))
149  return hr;
150 
151  level_count = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
152  for (level = srclevel + 1; level < level_count; level++)
153  {
154  IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, level, &mip_volume);
155  hr = D3DXLoadVolumeFromVolume(mip_volume, palette, NULL, top_volume, palette, NULL, filter, 0);
156  IDirect3DVolume9_Release(top_volume);
157  top_volume = mip_volume;
158 
159  if (FAILED(hr))
160  break;
161  }
162 
163  IDirect3DVolume9_Release(top_volume);
164  if (FAILED(hr))
165  return hr;
166 
167  return D3D_OK;
168  }
169 
170  default:
171  return D3DERR_INVALIDCALL;
172  }
173 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
GLint level
Definition: gl.h:1546
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1127
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:937
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:2233
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:1122
#define D3DERR_INVALIDCALL
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT WINAPI D3DXLoadVolumeFromVolume(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, IDirect3DVolume9 *src_volume, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:291
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DX_FILTER_BOX
Definition: d3dx9tex.h:31
#define IDirect3DBaseTexture9_GetType(p)
Definition: d3d9.h:844
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
#define IDirect3DVolume9_Release(p)
Definition: d3d9.h:383
static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
Definition: texture.c:37
static HPALETTE palette
Definition: clipboard.c:1345
#define D3D_OK
Definition: d3d.h:106
#define D3DX_FILTER_DITHER
Definition: d3dx9tex.h:36
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
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IDirect3DVolumeTexture9_GetVolumeLevel(p, a, b)
Definition: d3d9.h:1128
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static BOOL is_pow2(UINT num)
Definition: texture.c:32
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
enum _D3DRESOURCETYPE D3DRESOURCETYPE

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileInMemoryEx(), D3DXRenderToEnvMap_End(), and test_D3DXFilterTexture().

◆ D3DXSaveTextureToFileA()

HRESULT WINAPI D3DXSaveTextureToFileA ( const char dst_filename,
D3DXIMAGE_FILEFORMAT  file_format,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY src_palette 
)

Definition at line 1839 of file texture.c.

1841 {
1842  int len;
1843  WCHAR *filename;
1844  HRESULT hr;
1846 
1847  TRACE("(%s, %#x, %p, %p): relay\n",
1848  wine_dbgstr_a(dst_filename), file_format, src_texture, src_palette);
1849 
1850  if (!dst_filename) return D3DERR_INVALIDCALL;
1851 
1852  len = MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, NULL, 0);
1853  filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1854  if (!filename) return E_OUTOFMEMORY;
1855  MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, filename, len);
1856 
1857  hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, src_texture, src_palette);
1858  if (SUCCEEDED(hr))
1859  {
1862  }
1863 
1865  return hr;
1866 }
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:186
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:135
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
if SUCCEEDED(hr)
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN
Definition: util.c:186
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
GLenum GLsizei len
Definition: glext.h:6722
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define HeapFree(x, y, z)
Definition: compat.h:594
HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
Definition: texture.c:1889

◆ D3DXSaveTextureToFileInMemory()

HRESULT WINAPI D3DXSaveTextureToFileInMemory ( ID3DXBuffer **  dst_buffer,
D3DXIMAGE_FILEFORMAT  file_format,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY src_palette 
)

Definition at line 1889 of file texture.c.

1891 {
1892  HRESULT hr;
1894  IDirect3DSurface9 *surface;
1895 
1896  TRACE("(%p, %#x, %p, %p)\n",
1897  dst_buffer, file_format, src_texture, src_palette);
1898 
1899  if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL;
1900 
1901  if (file_format == D3DXIFF_DDS)
1902  return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette);
1903 
1904  type = IDirect3DBaseTexture9_GetType(src_texture);
1905  switch (type)
1906  {
1907  case D3DRTYPE_TEXTURE:
1908  case D3DRTYPE_CUBETEXTURE:
1909  hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
1910  break;
1912  FIXME("Volume textures aren't supported yet\n");
1913  return E_NOTIMPL;
1914  default:
1915  return D3DERR_INVALIDCALL;
1916  }
1917 
1918  if (SUCCEEDED(hr))
1919  {
1920  hr = D3DXSaveSurfaceToFileInMemory(dst_buffer, file_format, surface, src_palette, NULL);
1921  IDirect3DSurface9_Release(surface);
1922  }
1923 
1924  return hr;
1925 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
if SUCCEEDED(hr)
#define FIXME(fmt,...)
Definition: debug.h:111
#define IDirect3DBaseTexture9_GetType(p)
Definition: d3d9.h:844
HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN
Definition: surface.c:672
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect)
Definition: surface.c:2414
static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
Definition: texture.c:37
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
enum _D3DRESOURCETYPE D3DRESOURCETYPE

Referenced by D3DXSaveTextureToFileA(), D3DXSaveTextureToFileW(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXSaveTextureToFileW()

HRESULT WINAPI D3DXSaveTextureToFileW ( const WCHAR dst_filename,
D3DXIMAGE_FILEFORMAT  file_format,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY src_palette 
)

Definition at line 1868 of file texture.c.

1870 {
1871  HRESULT hr;
1873 
1874  TRACE("(%s, %#x, %p, %p): relay\n",
1875  wine_dbgstr_w(dst_filename), file_format, src_texture, src_palette);
1876 
1877  if (!dst_filename) return D3DERR_INVALIDCALL;
1878 
1879  hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, src_texture, src_palette);
1880  if (SUCCEEDED(hr))
1881  {
1882  hr = write_buffer_to_file(dst_filename, buffer);
1884  }
1885 
1886  return hr;
1887 }
HRESULT hr
Definition: shlfolder.c:183
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
if SUCCEEDED(hr)
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN
Definition: util.c:186
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
Definition: texture.c:1889

◆ fill_texture()

static void fill_texture ( const struct pixel_format_desc format,
BYTE pos,
const D3DXVECTOR4 value 
)
inlinestatic

Definition at line 1267 of file texture.c.

1268 {
1269  DWORD c;
1270 
1271  for (c = 0; c < format->bytes_per_pixel; c++)
1272  pos[c] = 0;
1273 
1274  for (c = 0; c < 4; c++)
1275  {
1276  float comp_value;
1277  DWORD i, v = 0, mask32 = format->bits[c] == 32 ? ~0U : ((1 << format->bits[c]) - 1);
1278 
1279  switch (c)
1280  {
1281  case 0: /* Alpha */
1282  comp_value = value->w;
1283  break;
1284  case 1: /* Red */
1285  comp_value = value->x;
1286  break;
1287  case 2: /* Green */
1288  comp_value = value->y;
1289  break;
1290  case 3: /* Blue */
1291  comp_value = value->z;
1292  break;
1293  }
1294 
1295  if (format->type == FORMAT_ARGBF16)
1297  else if (format->type == FORMAT_ARGBF)
1298  v = *(DWORD *)&comp_value;
1299  else if (format->type == FORMAT_ARGB)
1300  v = comp_value * ((1 << format->bits[c]) - 1) + 0.5f;
1301  else
1302  FIXME("Unhandled format type %#x\n", format->type);
1303 
1304  for (i = 0; i < format->bits[c] + format->shift[c]; i += 8)
1305  {
1306  BYTE byte, mask;
1307 
1308  if (format->shift[c] > i)
1309  {
1310  mask = mask32 << (format->shift[c] - i);
1311  byte = (v << (format->shift[c] - i)) & mask;
1312  }
1313  else
1314  {
1315  mask = mask32 >> (i - format->shift[c]);
1316  byte = (v >> (i - format->shift[c])) & mask;
1317  }
1318  pos[i / 8] |= byte;
1319  }
1320  }
1321 }
Definition: pdh_main.c:93
#define U(x)
Definition: wordpad.c:45
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLenum GLint GLuint mask
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:111
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: xxhash.c:193
const GLdouble * v
Definition: gl.h:2040
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 byte(x, n)
Definition: tomcrypt.h:118
#define c
Definition: ke_i.h:80
unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN
Definition: math.c:2102
static int comp_value(const WCHAR *ptr, int dpc)
Definition: htmlbody.c:68

Referenced by D3DXFillCubeTexture(), D3DXFillTexture(), and D3DXFillVolumeTexture().

◆ get_alpha_replacement_format()

static D3DFORMAT get_alpha_replacement_format ( D3DFORMAT  format)
static

Definition at line 545 of file texture.c.

546 {
547  static const struct
548  {
549  D3DFORMAT orig_format;
550  D3DFORMAT replacement_format;
551  }
552  replacement_formats[] =
553  {
559  };
560  unsigned int i;
561 
562  for (i = 0; i < ARRAY_SIZE(replacement_formats); ++i)
563  if (replacement_formats[i].orig_format == format)
564  return replacement_formats[i].replacement_format;
565  return format;
566 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
enum _D3DFORMAT D3DFORMAT
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 ARRAY_SIZE(a)
Definition: main.h:24

Referenced by D3DXCreateTextureFromFileInMemoryEx().

◆ get_cube_coord()

static float get_cube_coord ( enum cube_coord  coord,
unsigned int  x,
unsigned int  y,
unsigned int  size 
)
static

Definition at line 1673 of file texture.c.

1674 {
1675  switch (coord)
1676  {
1677  case XCOORD:
1678  return x + 0.5f;
1679  case XCOORDINV:
1680  return size - x - 0.5f;
1681  case YCOORD:
1682  return y + 0.5f;
1683  case YCOORDINV:
1684  return size - y - 0.5f;
1685  case ZERO:
1686  return 0.0f;
1687  case ONE:
1688  return size;
1689  default:
1690  ERR("Unexpected coordinate value\n");
1691  return 0.0f;
1692  }
1693 }
Definition: texture.c:1670
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
Definition: texture.c:1669
GLuint coord
Definition: glext.h:9511
GLsizeiptr size
Definition: glext.h:5919
#define ERR(fmt,...)
Definition: debug.h:110
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by D3DXFillCubeTexture().

◆ get_replacement_format()

static D3DFORMAT get_replacement_format ( D3DFORMAT  format)
static

Definition at line 175 of file texture.c.

176 {
177  static const struct
178  {
180  D3DFORMAT replacement_format;
181  }
182  replacements[] =
183  {
191  {D3DFMT_DXT4,