ReactOS  0.4.15-dev-2329-g3ad573f
util.c File Reference
#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 235 of file util.c.

Function Documentation

◆ D3DXDebugMute()

BOOL WINAPI D3DXDebugMute ( BOOL  mute)

Definition at line 303 of file util.c.

304 {
305  return FALSE;
306 }
#define FALSE
Definition: types.h:117

◆ D3DXGetDriverLevel()

UINT WINAPI D3DXGetDriverLevel ( struct IDirect3DDevice9 *  device)

Definition at line 312 of file util.c.

313 {
314  return 900;
315 }

◆ debug_d3dxparameter_class()

const char* debug_d3dxparameter_class ( D3DXPARAMETER_CLASS  c)

Definition at line 237 of file util.c.

238 {
239  switch (c)
240  {
247  default:
248  FIXME("Unrecognized D3DXPARAMETER_CLASS %#x.\n", c);
249  return "unrecognized";
250  }
251 }
#define FIXME(fmt,...)
Definition: debug.h:111
const GLubyte * c
Definition: glext.h:8905
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235

Referenced by d3dx_effect_GetMatrix(), d3dx_effect_GetMatrixArray(), d3dx_effect_GetMatrixPointerArray(), d3dx_effect_GetMatrixTranspose(), d3dx_effect_GetMatrixTransposeArray(), d3dx_effect_GetMatrixTransposePointerArray(), d3dx_effect_GetVector(), d3dx_effect_GetVectorArray(), d3dx_effect_SetBoolArray(), d3dx_effect_SetFloatArray(), d3dx_effect_SetIntArray(), d3dx_effect_SetMatrix(), d3dx_effect_SetMatrixArray(), d3dx_effect_SetMatrixPointerArray(), d3dx_effect_SetMatrixTranspose(), d3dx_effect_SetMatrixTransposeArray(), d3dx_effect_SetMatrixTransposePointerArray(), d3dx_effect_SetVector(), d3dx_effect_SetVectorArray(), d3dx_parse_effect_typedef(), d3dx_parse_init_value(), d3dx_parse_resource(), d3dx_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 283 of file util.c.

284 {
285  switch (r)
286  {
291  default:
292  FIXME("Unrecognized D3DXREGISTER_SET %#x.\n", r);
293  return "unrecognized";
294  }
295 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define FIXME(fmt,...)
Definition: debug.h:111
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235

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

◆ debug_d3dxparameter_type()

const char* debug_d3dxparameter_type ( D3DXPARAMETER_TYPE  t)

Definition at line 253 of file util.c.

254 {
255  switch (t)
256  {
277  default:
278  FIXME("Unrecognized D3DXPARAMETER_TYP %#x.\n", t);
279  return "unrecognized";
280  }
281 }
GLdouble GLdouble t
Definition: gl.h:2047
#define FIXME(fmt,...)
Definition: debug.h:111
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235

Referenced by d3dx_effect_GetValue(), d3dx_parse_effect_typedef(), d3dx_parse_resource(), d3dx_parse_value(), free_parameter(), free_parameter_object_data(), parse_ctab_constant_type(), and set_value().

◆ get_format_info()

const struct pixel_format_desc* get_format_info ( D3DFORMAT  format)

Definition at line 217 of file util.c.

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

Referenced by calculate_dds_surface_size(), check_texture_requirements(), convert_argb_pixels(), D3DXFillCubeTexture(), D3DXFillTexture(), D3DXFillVolumeTexture(), D3DXLoadSurfaceFromFileInMemory(), D3DXLoadSurfaceFromMemory(), D3DXLoadSurfaceFromSurface(), 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 226 of file util.c.

227 {
228  if(idx >= ARRAY_SIZE(formats))
229  return NULL;
231  return NULL;
232  return &formats[idx];
233 }
static const struct pixel_format_desc formats[]
Definition: util.c:59
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int idx
Definition: utils.c:41
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112

Referenced by check_texture_requirements().

◆ index_to_rgba()

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

Definition at line 43 of file util.c.

44 {
45  ULONG idx = (ULONG)(index->x * 255.0f + 0.5f);
46 
47  rgba->x = palette[idx].peRed / 255.0f;
48  rgba->y = palette[idx].peGreen / 255.0f;
49  rgba->z = palette[idx].peBlue / 255.0f;
50  rgba->w = palette[idx].peFlags / 255.0f; /* peFlags is the alpha component in DX8 and higher */
51 }
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:38
static HPALETTE palette
Definition: clipboard.c:1345
float z
Definition: d3dx9_private.h:38
unsigned int ULONG
Definition: retypes.h:1
float x
Definition: d3dx9_private.h:38
float y
Definition: d3dx9_private.h:38

◆ la_from_rgba()

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

Definition at line 29 of file util.c.

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

◆ la_to_rgba()

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

Definition at line 35 of file util.c.

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

◆ load_resource_into_memory()

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

Definition at line 170 of file util.c.

171 {
173 
174  *length = SizeofResource(module, resinfo);
175  if(*length == 0) return HRESULT_FROM_WIN32(GetLastError());
176 
177  resource = LoadResource(module, resinfo);
178  if( !resource ) return HRESULT_FROM_WIN32(GetLastError());
179 
181  if(*buffer == NULL) return HRESULT_FROM_WIN32(GetLastError());
182 
183  return S_OK;
184 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
GLuint buffer
Definition: glext.h:5915
int resource
Definition: rdpsnd_sgi.c:44
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
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 120 of file util.c.

121 {
122  HANDLE hfile, hmapping = NULL;
123 
125  if(hfile == INVALID_HANDLE_VALUE) goto error;
126 
127  *length = GetFileSize(hfile, NULL);
128  if(*length == INVALID_FILE_SIZE) goto error;
129 
130  hmapping = CreateFileMappingW(hfile, NULL, PAGE_READONLY, 0, 0, NULL);
131  if(!hmapping) goto error;
132 
133  *buffer = MapViewOfFile(hmapping, FILE_MAP_READ, 0, 0, 0);
134  if(*buffer == NULL) goto error;
135 
136  CloseHandle(hmapping);
137  CloseHandle(hfile);
138 
139  return S_OK;
140 
141 error:
142  if (hmapping)
143  CloseHandle(hmapping);
144  if (hfile != INVALID_HANDLE_VALUE)
145  CloseHandle(hfile);
147 }
#define CloseHandle
Definition: compat.h:598
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define MapViewOfFile
Definition: compat.h:604
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
#define INVALID_FILE_SIZE
Definition: winbase.h:545
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define FILE_MAP_READ
Definition: compat.h:635
#define OPEN_EXISTING
Definition: compat.h:634
void error(char *format,...)
Definition: util.c:72
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:603
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define GENERIC_READ
Definition: compat.h:135
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
#define CreateFileW
Definition: compat.h:600

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 186 of file util.c.

187 {
188  HRESULT hr = S_OK;
189  void *buffer_pointer;
191  DWORD bytes_written;
193  if (file == INVALID_HANDLE_VALUE)
195 
196  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
198 
199  if (!WriteFile(file, buffer_pointer, buffer_size, &bytes_written, NULL))
201 
202  CloseHandle(file);
203  return hr;
204 }
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:598
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
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:888
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define S_OK
Definition: intsafe.h:51
#define CREATE_ALWAYS
Definition: disk.h:72
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
Definition: fci.c:126

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

Variable Documentation

◆ formats