From 74c6321a1517cc1d9b1e6ba0453c84a6b0244d77 Mon Sep 17 00:00:00 2001 From: Raphael Junqueira Date: Thu, 3 Nov 2005 09:54:31 +0000 Subject: [PATCH] - defined D3DCOLOR_B macros to access byte values of D3DCOLOR - use D3DCOLOR macros instead of using shift + masks - fix a bug where diffuse.lpData checked instead of specular.lpData - implement color fixup on ARB VShader compilation code: -> on input parameters using swizzle -> add is_color parameter on vshader_program_add_param --- dlls/d3d8/d3d8_private.h | 4 ++++ dlls/d3d8/device.c | 8 ++++---- dlls/d3d8/drawprim.c | 34 +++++++++++++++++----------------- dlls/d3d8/vshaderdeclaration.c | 17 ++++++++--------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 7b92897f715..9cec1c68d67 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -299,6 +299,10 @@ struct PLIGHTINFOEL { #define GL_EXTCALL(FuncName) (This->direct3d8->gl_info.FuncName) #define GL_EXTCALL_DEV(FuncName, dev) ((dev)->direct3d8->gl_info.FuncName) +#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF) +#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF) +#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF) +#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF) #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f) #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index b1df7b984e6..3d2d0ef8d7b 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1411,10 +1411,10 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count if (Flags & D3DCLEAR_TARGET) { TRACE("Clearing screen with glClear to color %lx\n", Color); glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value); - glClearColor(((Color >> 16) & 0xFF) / 255.0f, - ((Color >> 8) & 0xFF) / 255.0f, - ((Color >> 0) & 0xFF) / 255.0f, - ((Color >> 24) & 0xFF) / 255.0f); + glClearColor(D3DCOLOR_R(Color), + D3DCOLOR_G(Color), + D3DCOLOR_B(Color), + D3DCOLOR_A(Color)); checkGLcall("glClearColor"); /* Clear ALL colors! */ diff --git a/dlls/d3d8/drawprim.c b/dlls/d3d8/drawprim.c index 78c11bc969a..445aefd4fad 100644 --- a/dlls/d3d8/drawprim.c +++ b/dlls/d3d8/drawprim.c @@ -1159,30 +1159,30 @@ static void drawStridedSlow(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData * /* Diffuse -------------------------------- */ if (sd->u.s.diffuse.lpData != NULL) { - glColor4ub((diffuseColor >> 16) & 0xFF, - (diffuseColor >> 8) & 0xFF, - (diffuseColor >> 0) & 0xFF, - (diffuseColor >> 24) & 0xFF); - VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n", - ((diffuseColor >> 16) & 0xFF) / 255.0f, - ((diffuseColor >> 8) & 0xFF) / 255.0f, - ((diffuseColor >> 0) & 0xFF) / 255.0f, - ((diffuseColor >> 24) & 0xFF) / 255.0f)); + glColor4ub(D3DCOLOR_B_R(diffuseColor), + D3DCOLOR_B_G(diffuseColor), + D3DCOLOR_B_B(diffuseColor), + D3DCOLOR_B_A(diffuseColor)); + VTRACE(("glColor4ub: r,g,b,a=%u,%u,%u,%u\n", + D3DCOLOR_B_R(diffuseColor), + D3DCOLOR_B_G(diffuseColor), + D3DCOLOR_B_B(diffuseColor), + D3DCOLOR_B_A(diffuseColor))); } else { if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } /* Specular ------------------------------- */ - if (sd->u.s.diffuse.lpData != NULL) { - VTRACE(("glSecondaryColor4ub: r,g,b=%f,%f,%f\n", - ((specularColor >> 16) & 0xFF) / 255.0f, - ((specularColor >> 8) & 0xFF) / 255.0f, - ((specularColor >> 0) & 0xFF) / 255.0f)); + if (sd->u.s.specular.lpData != NULL) { + VTRACE(("glSecondaryColor4ub: r,g,b=%u,%u,%u\n", + D3DCOLOR_B_R(specularColor), + D3DCOLOR_B_G(specularColor), + D3DCOLOR_B_B(specularColor))); if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { GL_EXTCALL(glSecondaryColor3ubEXT)( - (specularColor >> 16) & 0xFF, - (specularColor >> 8) & 0xFF, - (specularColor >> 0) & 0xFF); + D3DCOLOR_B_R(specularColor), + D3DCOLOR_B_G(specularColor), + D3DCOLOR_B_B(specularColor)); } else { /* Do not worry if specular colour missing and disable request */ VTRACE(("Specular color extensions not supplied\n")); diff --git a/dlls/d3d8/vshaderdeclaration.c b/dlls/d3d8/vshaderdeclaration.c index 72fc518463c..f41b6137547 100644 --- a/dlls/d3d8/vshaderdeclaration.c +++ b/dlls/d3d8/vshaderdeclaration.c @@ -511,10 +511,10 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInputSW(IDirect3DDevice8Impl* dw = *(const DWORD*) curPos; curPos = curPos + sizeof(DWORD); /**/ - vshader->input.V[reg].x = (float) (((dw >> 16) & 0xFF) / 255.0f); - vshader->input.V[reg].y = (float) (((dw >> 8) & 0xFF) / 255.0f); - vshader->input.V[reg].z = (float) (((dw >> 0) & 0xFF) / 255.0f); - vshader->input.V[reg].w = (float) (((dw >> 24) & 0xFF) / 255.0f); + vshader->input.V[reg].x = D3DCOLOR_R(dw); + vshader->input.V[reg].y = D3DCOLOR_G(dw); + vshader->input.V[reg].z = D3DCOLOR_B(dw); + vshader->input.V[reg].w = D3DCOLOR_A(dw); break; case D3DVSDT_SHORT2: @@ -549,11 +549,10 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInputSW(IDirect3DDevice8Impl* dw = *(const DWORD*) curPos; curPos = curPos + sizeof(DWORD); /**/ - vshader->input.V[reg].x = (float) ((dw & 0x000F) >> 0); - vshader->input.V[reg].y = (float) ((dw & 0x00F0) >> 8); - vshader->input.V[reg].z = (float) ((dw & 0x0F00) >> 16); - vshader->input.V[reg].w = (float) ((dw & 0xF000) >> 24); - + vshader->input.V[reg].x = (float) ((dw & 0x000000FF) >> 0); + vshader->input.V[reg].y = (float) ((dw & 0x0000FF00) >> 8); + vshader->input.V[reg].z = (float) ((dw & 0x00FF0000) >> 16); + vshader->input.V[reg].w = (float) ((dw & 0xFF000000) >> 24); break; default: /** errooooorr what to do ? */ -- 2.11.4.GIT