mirror of
https://github.com/reactos/reactos.git
synced 2024-11-24 12:03:31 +08:00
[WINESYNC] d3dx9: Merge the d3dx_effect_GetInt() helper.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id 5015e2a7cf5fa3779fd651817058e03c94807088 by Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
parent
b1ee53bf49
commit
218bc69a38
@ -1392,44 +1392,6 @@ static HRESULT d3dx9_base_effect_set_int(struct d3dx9_base_effect *base, D3DXHAN
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_base_effect_get_int(struct d3dx9_base_effect *base, D3DXHANDLE parameter, INT *n)
|
||||
{
|
||||
struct d3dx_parameter *param = get_valid_parameter(base, parameter);
|
||||
|
||||
if (n && param && !param->element_count)
|
||||
{
|
||||
if (param->columns == 1 && param->rows == 1)
|
||||
{
|
||||
set_number(n, D3DXPT_INT, param->data, param->type);
|
||||
TRACE("Returning %i\n", *n);
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
if (param->type == D3DXPT_FLOAT &&
|
||||
((param->class == D3DXPC_VECTOR && param->columns != 2)
|
||||
|| (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
|
||||
{
|
||||
TRACE("Vector fixup\n");
|
||||
|
||||
/* all components (3,4) are clamped (0,255) and put in the INT */
|
||||
*n = (INT)(min(max(0.0f, *((FLOAT *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI);
|
||||
*n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
|
||||
*n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
|
||||
if (param->columns * param->rows > 3)
|
||||
{
|
||||
*n += ((INT)(min(max(0.0f, *((FLOAT *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
|
||||
}
|
||||
|
||||
TRACE("Returning %i\n", *n);
|
||||
return D3D_OK;
|
||||
}
|
||||
}
|
||||
|
||||
WARN("Parameter not found.\n");
|
||||
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_base_effect_set_int_array(struct d3dx9_base_effect *base,
|
||||
D3DXHANDLE parameter, const INT *n, UINT count)
|
||||
{
|
||||
@ -3426,10 +3388,39 @@ static HRESULT WINAPI d3dx_effect_SetInt(ID3DXEffect *iface, D3DXHANDLE paramete
|
||||
static HRESULT WINAPI d3dx_effect_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
|
||||
{
|
||||
struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
|
||||
struct d3dx_parameter *param = get_valid_parameter(&effect->base_effect, parameter);
|
||||
|
||||
TRACE("iface %p, parameter %p, n %p.\n", iface, parameter, n);
|
||||
|
||||
return d3dx9_base_effect_get_int(&effect->base_effect, parameter, n);
|
||||
if (n && param && !param->element_count)
|
||||
{
|
||||
if (param->columns == 1 && param->rows == 1)
|
||||
{
|
||||
set_number(n, D3DXPT_INT, param->data, param->type);
|
||||
TRACE("Returning %d.\n", *n);
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
if (param->type == D3DXPT_FLOAT &&
|
||||
((param->class == D3DXPC_VECTOR && param->columns != 2)
|
||||
|| (param->class == D3DXPC_MATRIX_ROWS && param->rows != 2 && param->columns == 1)))
|
||||
{
|
||||
TRACE("Vector fixup.\n");
|
||||
|
||||
*n = min(max(0.0f, *((float *)param->data + 2)), 1.0f) * INT_FLOAT_MULTI;
|
||||
*n += ((int)(min(max(0.0f, *((float *)param->data + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
|
||||
*n += ((int)(min(max(0.0f, *((float *)param->data + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
|
||||
if (param->columns * param->rows > 3)
|
||||
*n += ((int)(min(max(0.0f, *((float *)param->data + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
|
||||
|
||||
TRACE("Returning %d.\n", *n);
|
||||
return D3D_OK;
|
||||
}
|
||||
}
|
||||
|
||||
WARN("Parameter not found.\n");
|
||||
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3dx_effect_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, const INT *n, UINT count)
|
||||
|
@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc
|
||||
include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h,
|
||||
include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
|
||||
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h}
|
||||
tags: {wine: 86dff681fc6c36a77b84ec7ded4dfc3f889e2882}
|
||||
tags: {wine: 5015e2a7cf5fa3779fd651817058e03c94807088}
|
||||
|
Loading…
Reference in New Issue
Block a user