ReactOS  0.4.14-dev-384-g5b37caa
util.c File Reference
#include "config.h"
#include "wine/port.h"
#include "d3dx9_private.h"
Include dependency graph for util.c:

Go to the source code of this file.

Macros

#define WINE_D3DX_TO_STR(x)   case x: return #x
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static void la_from_rgba (const struct vec4 *rgba, struct vec4 *la)
 
static void la_to_rgba (const struct vec4 *la, struct vec4 *rgba, const PALETTEENTRY *palette)
 
static void index_to_rgba (const struct vec4 *index, struct vec4 *rgba, const PALETTEENTRY *palette)
 
HRESULT map_view_of_file (const WCHAR *filename, void **buffer, DWORD *length)
 
HRESULT load_resource_into_memory (HMODULE module, HRSRC resinfo, void **buffer, DWORD *length)
 
HRESULT write_buffer_to_file (const WCHAR *dst_filename, ID3DXBuffer *buffer)
 
const struct pixel_format_descget_format_info (D3DFORMAT format)
 
const struct pixel_format_descget_format_info_idx (int idx)
 
const chardebug_d3dxparameter_class (D3DXPARAMETER_CLASS c)
 
const chardebug_d3dxparameter_type (D3DXPARAMETER_TYPE t)
 
const chardebug_d3dxparameter_registerset (D3DXREGISTER_SET r)
 
BOOL WINAPI D3DXDebugMute (BOOL mute)
 
UINT WINAPI D3DXGetDriverLevel (struct IDirect3DDevice9 *device)
 

Variables

static const struct pixel_format_desc formats []
 

Macro Definition Documentation

◆ WINE_D3DX_TO_STR

#define WINE_D3DX_TO_STR (   x)    case x: return #x

Definition at line 231 of file util.c.

Function Documentation

◆ D3DXDebugMute()

BOOL WINAPI D3DXDebugMute ( BOOL  mute)

Definition at line 299 of file util.c.

300 {
301  return FALSE;
302 }

◆ D3DXGetDriverLevel()

UINT WINAPI D3DXGetDriverLevel ( struct IDirect3DDevice9 *  device)

Definition at line 308 of file util.c.

309 {
310  return 900;
311 }

◆ debug_d3dxparameter_class()

const char* debug_d3dxparameter_class ( D3DXPARAMETER_CLASS  c)

Definition at line 233 of file util.c.

234 {
235  switch (c)
236  {
243  default:
244  FIXME("Unrecognized D3DXPARAMETER_CLASS %#x.\n", c);
245  return "unrecognized";
246  }
247 }
#define FIXME(fmt,...)
Definition: debug.h:110
const GLubyte * c
Definition: glext.h:8905
#define WINE_D3DX_TO_STR(x)
Definition: util.c:231

Referenced by d3dx9_base_effect_get_matrix(), d3dx9_base_effect_get_matrix_array(), d3dx9_base_effect_get_matrix_pointer_array(), d3dx9_base_effect_get_matrix_transpose(), d3dx9_base_effect_get_matrix_transpose_array(), d3dx9_base_effect_get_matrix_transpose_pointer_array(), d3dx9_base_effect_get_vector(), d3dx9_base_effect_get_vector_array(), d3dx9_base_effect_set_bool_array(), d3dx9_base_effect_set_float_array(), d3dx9_base_effect_set_int_array(), d3dx9_base_effect_set_matrix(), d3dx9_base_effect_set_matrix_array(), d3dx9_base_effect_set_matrix_pointer_array(), d3dx9_base_effect_set_matrix_transpose(), d3dx9_base_effect_set_matrix_transpose_array(), d3dx9_base_effect_set_matrix_transpose_pointer_array(), d3dx9_base_effect_set_vector(), d3dx9_base_effect_set_vector_array(), d3dx9_parse_effect_typedef(), d3dx9_parse_init_value(), d3dx9_parse_resource(), d3dx9_parse_value(), ID3DXConstantTableImpl_SetValue(), parse_ctab_constant_type(), set(), set_matrix_array(), set_matrix_pointer_array(), set_scalar(), set_scalar_array(), set_vector(), and set_vector_array().

◆ debug_d3dxparameter_registerset()

const char* debug_d3dxparameter_registerset ( D3DXREGISTER_SET  r)

Definition at line 279 of file util.c.

280 {
281  switch (r)
282  {
287  default:
288  FIXME("Unrecognized D3DXREGISTER_SET %#x.\n", r);
289  return "unrecognized";
290  }
291 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINE_D3DX_TO_STR(x)
Definition: util.c:231

Referenced by ID3DXConstantTableImpl_SetDefaults(), parse_ctab_constant_type(), and set().

◆ debug_d3dxparameter_type()

const char* debug_d3dxparameter_type ( D3DXPARAMETER_TYPE  t)

Definition at line 249 of file util.c.

250 {
251  switch (t)
252  {
273  default:
274  FIXME("Unrecognized D3DXPARAMETER_TYP %#x.\n", t);
275  return "unrecognized";
276  }
277 }
GLdouble GLdouble t
Definition: gl.h:2047
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINE_D3DX_TO_STR(x)
Definition: util.c:231

Referenced by d3dx9_base_effect_get_value(), d3dx9_base_effect_set_value(), d3dx9_parse_effect_typedef(), d3dx9_parse_resource(), d3dx9_parse_value(), free_parameter(), free_parameter_data(), and parse_ctab_constant_type().

◆ get_format_info()

const struct pixel_format_desc* get_format_info ( D3DFORMAT  format)

Definition at line 213 of file util.c.

214 {
215  unsigned int i = 0;
216  while(formats[i].format != format && formats[i].format != D3DFMT_UNKNOWN) i++;
217  if (formats[i].format == D3DFMT_UNKNOWN)
218  FIXME("Unknown format %#x (as FOURCC %s).\n", format, debugstr_an((const char *)&format, 4));
219  return &formats[i];
220 }
static const struct pixel_format_desc formats[]
Definition: util.c:57
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
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 FIXME(fmt,...)
Definition: debug.h:110
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47

Referenced by calculate_dds_surface_size(), convert_argb_pixels(), D3DXCheckTextureRequirements(), D3DXFillCubeTexture(), D3DXFillTexture(), D3DXFillVolumeTexture(), D3DXLoadSurfaceFromFileInMemory(), D3DXLoadSurfaceFromMemory(), D3DXLoadVolumeFromMemory(), D3DXSaveSurfaceToFileInMemory(), point_filter_argb_pixels(), and save_dds_surface_to_memory().

◆ get_format_info_idx()

const struct pixel_format_desc* get_format_info_idx ( int  idx)

Definition at line 222 of file util.c.

223 {
224  if(idx >= ARRAY_SIZE(formats))
225  return NULL;
227  return NULL;
228  return &formats[idx];
229 }
static const struct pixel_format_desc formats[]
Definition: util.c:57
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by D3DXCheckTextureRequirements().

◆ index_to_rgba()

static void index_to_rgba ( const struct vec4 index,
struct vec4 rgba,
const PALETTEENTRY palette 
)
static

Definition at line 41 of file util.c.

42 {
43  ULONG idx = (ULONG)(index->x * 255.0f + 0.5f);
44 
45  rgba->x = palette[idx].peRed / 255.0f;
46  rgba->y = palette[idx].peGreen / 255.0f;
47  rgba->z = palette[idx].peBlue / 255.0f;
48  rgba->w = palette[idx].peFlags / 255.0f; /* peFlags is the alpha component in DX8 and higher */
49 }
static ULONG
Definition: util.c:35
unsigned int idx
Definition: utils.c:41
GLuint index
Definition: glext.h:6031
float w
Definition: d3dx9_private.h:37
static HPALETTE palette
Definition: clipboard.c:1345
float z
Definition: d3dx9_private.h:37
unsigned int ULONG
Definition: retypes.h:1
float x
Definition: d3dx9_private.h:37
float y
Definition: d3dx9_private.h:37

◆ la_from_rgba()

static void la_from_rgba ( const struct vec4 rgba,
struct vec4 la 
)
static

Definition at line 27 of file util.c.

28 {
29  la->x = rgba->x * 0.2125f + rgba->y * 0.7154f + rgba->z * 0.0721f;
30  la->w = rgba->w;
31 }
float w
Definition: d3dx9_private.h:37
float z
Definition: d3dx9_private.h:37
float x
Definition: d3dx9_private.h:37
float y
Definition: d3dx9_private.h:37

◆ la_to_rgba()

static void la_to_rgba ( const struct vec4 la,
struct vec4 rgba,
const PALETTEENTRY palette 
)
static

Definition at line 33 of file util.c.

34 {
35  rgba->x = la->x;
36  rgba->y = la->x;
37  rgba->z = la->x;
38  rgba->w = la->w;
39 }
float w
Definition: d3dx9_private.h:37
float z
Definition: d3dx9_private.h:37
float x
Definition: d3dx9_private.h:37
float y
Definition: d3dx9_private.h:37

◆ load_resource_into_memory()

HRESULT load_resource_into_memory ( HMODULE  module,
HRSRC  resinfo,
void **  buffer,
DWORD length 
)

Definition at line 166 of file util.c.

167 {
169 
170  *length = SizeofResource(module, resinfo);
171  if(*length == 0) return HRESULT_FROM_WIN32(GetLastError());
172 
173  resource = LoadResource(module, resinfo);
174  if( !resource ) return HRESULT_FROM_WIN32(GetLastError());
175 
177  if(*buffer == NULL) return HRESULT_FROM_WIN32(GetLastError());
178 
179  return S_OK;
180 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
GLuint buffer
Definition: glext.h:5915
int resource
Definition: rdpsnd_sgi.c:44
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define S_OK
Definition: intsafe.h:59
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568

Referenced by D3DXAssembleShaderFromResourceA(), D3DXAssembleShaderFromResourceW(), D3DXCompileShaderFromResourceA(), D3DXCompileShaderFromResourceW(), D3DXCreateEffectCompilerFromResourceA(), D3DXCreateEffectCompilerFromResourceW(), D3DXCreateEffectFromResourceExA(), D3DXCreateEffectFromResourceExW(), D3DXCreateTextureFromResourceExA(), D3DXCreateTextureFromResourceExW(), D3DXGetImageInfoFromResourceA(), D3DXGetImageInfoFromResourceW(), D3DXLoadMeshFromXResource(), D3DXLoadSurfaceFromResourceA(), D3DXLoadSurfaceFromResourceW(), D3DXPreprocessShaderFromResourceA(), and D3DXPreprocessShaderFromResourceW().

◆ map_view_of_file()

HRESULT map_view_of_file ( const WCHAR filename,
void **  buffer,
DWORD length 
)

Definition at line 118 of file util.c.

119 {
120  HANDLE hfile, hmapping = NULL;
121 
123  if(hfile == INVALID_HANDLE_VALUE) goto error;
124 
125  *length = GetFileSize(hfile, NULL);
126  if(*length == INVALID_FILE_SIZE) goto error;
127 
128  hmapping = CreateFileMappingW(hfile, NULL, PAGE_READONLY, 0, 0, NULL);
129  if(!hmapping) goto error;
130 
131  *buffer = MapViewOfFile(hmapping, FILE_MAP_READ, 0, 0, 0);
132  if(*buffer == NULL) goto error;
133 
134  CloseHandle(hmapping);
135  CloseHandle(hfile);
136 
137  return S_OK;
138 
139 error:
140  CloseHandle(hmapping);
141  CloseHandle(hfile);
143 }
#define CloseHandle
Definition: compat.h:406
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define MapViewOfFile
Definition: compat.h:410
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define INVALID_FILE_SIZE
Definition: winbase.h:529
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:435
#define OPEN_EXISTING
Definition: compat.h:434
void error(char *format,...)
Definition: util.c:72
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:409
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define GENERIC_READ
Definition: compat.h:124
#define S_OK
Definition: intsafe.h:59
#define PAGE_READONLY
Definition: compat.h:127
#define CreateFileW
Definition: compat.h:408

Referenced by D3DXCreateCubeTextureFromFileA(), D3DXCreateCubeTextureFromFileExA(), D3DXCreateCubeTextureFromFileExW(), D3DXCreateCubeTextureFromFileW(), D3DXCreateEffectCompilerFromFileW(), D3DXCreateTextureFromFileExW(), D3DXCreateVolumeTextureFromFileA(), D3DXCreateVolumeTextureFromFileExA(), D3DXCreateVolumeTextureFromFileExW(), D3DXCreateVolumeTextureFromFileW(), D3DXGetImageInfoFromFileW(), D3DXLoadMeshFromXW(), D3DXLoadMeshHierarchyFromXW(), D3DXLoadSurfaceFromFileW(), and D3DXLoadVolumeFromFileW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

◆ write_buffer_to_file()

HRESULT write_buffer_to_file ( const WCHAR dst_filename,
ID3DXBuffer buffer 
)

Definition at line 182 of file util.c.

183 {
184  HRESULT hr = S_OK;
185  void *buffer_pointer;
187  DWORD bytes_written;
189  if (file == INVALID_HANDLE_VALUE)
191 
192  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
194 
195  if (!WriteFile(file, buffer_pointer, buffer_size, &bytes_written, NULL))
197 
198  CloseHandle(file);
199  return hr;
200 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:406
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define GENERIC_WRITE
Definition: nt_native.h:90
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
smooth NULL
Definition: ftsmooth.c:416
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileW
Definition: compat.h:408
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
Definition: fci.c:126

Referenced by D3DXSaveSurfaceToFileA(), D3DXSaveSurfaceToFileW(), D3DXSaveTextureToFileA(), and D3DXSaveTextureToFileW().

Variable Documentation

◆ formats