- 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
This commit is contained in:
Raphael Junqueira 2005-11-03 09:54:31 +00:00 committed by Alexandre Julliard
parent d7161472fc
commit 74c6321a15
4 changed files with 33 additions and 30 deletions

View File

@ -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)

View File

@ -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! */

View File

@ -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"));

View File

@ -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 ? */