Commit d52c5080 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- Fix compilation again using olders GL headers

(glCompressedTexImage2DARB problem). - Fix typo on constant. - Detection of NVidia texture_shader and register_combiners extensions. - Begin to implement BUMPMAPPING using NVidia Texture shader extension (not really working for now).
parent c349d7d2
......@@ -232,6 +232,7 @@ struct PLIGHTINFOEL {
#define GL_SUPPORT(ExtName) (TRUE == This->direct3d8->gl_info.supported[ExtName])
#define GL_SUPPORT_DEV(ExtName, dev) (TRUE == (dev)->direct3d8->gl_info.supported[ExtName])
#define GL_EXTCALL(FuncName) (This->direct3d8->gl_info.FuncName)
#define GL_EXTCALL_DEV(FuncName, dev) ((dev)->direct3d8->gl_info.FuncName)
#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
......@@ -359,6 +360,8 @@ struct IDirect3DDevice8Impl
PALETTEENTRY palettes[MAX_PALETTES][256];
UINT currentPalette;
BOOL texture_shader_active;
/* Optimization */
BOOL modelview_valid;
BOOL proj_valid;
......
......@@ -2975,6 +2975,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
}
case D3DRS_COLORWRITEENABLE :
{
TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
......@@ -2985,6 +2986,15 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
Value & D3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
checkGLcall("glColorMask(...)");
}
break;
case D3DRS_LOCALVIEWER :
{
GLint state = (Value) ? 1 : 0;
TRACE("Local Viewer Enable to %ul\n", (BOOL) Value);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, state);
}
break;
/* Unhandled yet...! */
......@@ -2999,7 +3009,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_WRAP5 :
case D3DRS_WRAP6 :
case D3DRS_WRAP7 :
case D3DRS_LOCALVIEWER :
case D3DRS_SOFTWAREVERTEXPROCESSING :
case D3DRS_POINTSPRITEENABLE :
case D3DRS_MULTISAMPLEANTIALIAS :
......@@ -3450,8 +3459,13 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
checkGLcall("Disable GL_TEXTURE_1D");
}
if (This->StateBlock->textureDimensions[Stage] == GL_TEXTURE_2D) {
if (GL_SUPPORT(NV_TEXTURE_SHADER) && This->texture_shader_active) {
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
checkGLcall("Enable GL_TEXTURE_2D");
} else {
glEnable(GL_TEXTURE_2D);
checkGLcall("Enable GL_TEXTURE_2D");
}
} else {
glDisable(GL_TEXTURE_2D);
checkGLcall("Disable GL_TEXTURE_2D");
......@@ -3637,9 +3651,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
}
break;
#if defined(GL_ARB_texture_cube_map) || defined(GL_NV_texgen_reflection)
case D3DTSS_TCI_CAMERASPACENORMAL:
{
if (GL_SUPPORT(GL_NV_texgen_reflection)) {
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
......@@ -3657,24 +3671,23 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
glEnable(GL_TEXTURE_GEN_S);
checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)");
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
glEnable(GL_TEXTURE_GEN_T);
checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)");
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
glEnable(GL_TEXTURE_GEN_R);
checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)");
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
}
}
break;
#endif
#if defined(GL_ARB_texture_cube_map) || defined(GL_NV_texgen_reflection)
case D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
{
if (GL_SUPPORT(GL_NV_texgen_reflection)) {
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
......@@ -3692,19 +3705,19 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
glEnable(GL_TEXTURE_GEN_S);
checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)");
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
glEnable(GL_TEXTURE_GEN_T);
checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)");
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
glEnable(GL_TEXTURE_GEN_R);
checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)");
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
}
}
break;
#endif
/* Unhandled types: */
default:
......@@ -3720,22 +3733,31 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
break;
/* Unhandled */
case D3DTSS_TEXTURETRANSFORMFLAGS :
set_texture_matrix((float *)&This->StateBlock->transforms[D3DTS_TEXTURE0 + Stage].u.m[0][0], Value);
break;
case D3DTSS_BUMPENVMAT00 :
case D3DTSS_BUMPENVMAT01 :
TRACE("BUMPENVMAT0%u Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT00, Stage, Type, Value);
TRACE("BUMPENVMAT0%u Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT00, Stage, Type, Value);
break;
case D3DTSS_BUMPENVMAT10 :
case D3DTSS_BUMPENVMAT11 :
TRACE("BUMPENVMAT1%u Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT10, Stage, Type, Value);
TRACE("BUMPENVMAT1%u Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT10, Stage, Type, Value);
break;
case D3DTSS_TEXTURETRANSFORMFLAGS :
set_texture_matrix((float *)&This->StateBlock->transforms[D3DTS_TEXTURE0 + Stage].u.m[0][0], Value);
case D3DTSS_BUMPENVLSCALE :
TRACE("BUMPENVLSCALE Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
break;
case D3DTSS_BUMPENVLSCALE :
case D3DTSS_BUMPENVLOFFSET :
TRACE("BUMPENVLOFFSET Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
break;
case D3DTSS_RESULTARG :
TRACE("RESULTARG Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
break;
default:
/* Put back later: FIXME("(%p) : stub, Stage=%ld, Type=%d, Value =%ld\n", This, Stage, Type, Value); */
TRACE("Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
......
......@@ -439,7 +439,7 @@ HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
case D3DFMT_DXT5:
case D3DFMT_X8L8V8U8:
case D3DFMT_L6V5U5:
case D3DFMT_V8U8:
/*case D3DFMT_V8U8:*/
case D3DFMT_L8:
/* Since we do not support these formats right now, don't pretend to. */
return D3DERR_NOTAVAILABLE;
......@@ -660,10 +660,10 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D
D3DSTENCILCAPS_KEEP |
D3DSTENCILCAPS_REPLACE |
D3DSTENCILCAPS_ZERO;
#if defined(GL_VERSION_1_4) || defined(GL_EXT_stencil_wrap)
if (GL_SUPPORT(EXT_STENCIL_WRAP)) {
pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
D3DSTENCILCAPS_INCR;
#endif
}
pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x80000;
......@@ -696,8 +696,8 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM;
}
pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP;
/* FIXME: Add
D3DTEXOPCAPS_BUMPENVMAP
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
D3DTEXOPCAPS_PREMODULATE */
......@@ -745,9 +745,9 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D
pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
D3DVTXPCAPS_MATERIALSOURCE7 |
D3DVTXPCAPS_POSITIONALLIGHTS |
D3DVTXPCAPS_LOCALVIEWER |
D3DVTXPCAPS_TEXGEN;
/* FIXME: Add
D3DVTXPCAPS_LOCALVIEWER
D3DVTXPCAPS_TWEENING */
pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
......@@ -932,6 +932,8 @@ static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface, Display* display) {
} else if (strcmp(ThisExtn, "GL_ARB_texture_cube_map") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Texture Cube Map support\n");
This->gl_info.supported[ARB_TEXTURE_CUBE_MAP] = TRUE;
TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support\n");
This->gl_info.supported[NV_TEXGEN_REFLECTION] = TRUE;
} else if (strcmp(ThisExtn, "GL_ARB_texture_compression") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Texture Compression support\n");
This->gl_info.supported[ARB_TEXTURE_COMPRESSION] = TRUE;
......@@ -970,6 +972,9 @@ static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface, Display* display) {
} else if (strcmp(ThisExtn, "GL_EXT_secondary_color") == 0) {
TRACE_(d3d_caps)(" FOUND: EXT Secondary coord support\n");
This->gl_info.supported[EXT_SECONDARY_COLOR] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_stencil_wrap") == 0) {
TRACE_(d3d_caps)(" FOUND: EXT Stencil wrap support\n");
This->gl_info.supported[EXT_STENCIL_WRAP] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_texture_compression_s3tc") == 0) {
TRACE_(d3d_caps)(" FOUND: EXT Texture S3TC compression support\n");
This->gl_info.supported[EXT_TEXTURE_COMPRESSION_S3TC] = TRUE;
......@@ -998,15 +1003,33 @@ static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface, Display* display) {
/**
* NVIDIA
*/
} else if (strcmp(ThisExtn, "GL_NV_texture_env_combine4") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Env combine (4) support\n");
This->gl_info.supported[NV_TEXTURE_ENV_COMBINE4] = TRUE;
} else if (strstr(ThisExtn, "GL_NV_fragment_program")) {
This->gl_info.ps_nv_version = PS_VERSION_11;
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Pixel Shader support - version=%02x\n", This->gl_info.ps_nv_version);
} else if (strstr(ThisExtn, "GL_NV_fog_distance")) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Fog Distance support\n");
This->gl_info.supported[NV_FOG_DISTANCE] = TRUE;
} else if (strstr(ThisExtn, "GL_NV_fragment_program")) {
This->gl_info.ps_nv_version = PS_VERSION_11;
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Pixel Shader support - version=%02x\n", This->gl_info.ps_nv_version);
} else if (strcmp(ThisExtn, "GL_NV_register_combiners") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Register combiners (1) support\n");
This->gl_info.supported[NV_REGISTER_COMBINERS] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_register_combiners2") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Register combiners (2) support\n");
This->gl_info.supported[NV_REGISTER_COMBINERS2] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_texgen_reflection") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Gen Reflection support\n");
This->gl_info.supported[NV_TEXGEN_REFLECTION] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_texture_env_combine4") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Env combine (4) support\n");
This->gl_info.supported[NV_TEXTURE_ENV_COMBINE4] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_texture_shader") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Shader (1) support\n");
This->gl_info.supported[NV_TEXTURE_SHADER] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_texture_shader2") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Shader (2) support\n");
This->gl_info.supported[NV_TEXTURE_SHADER2] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_texture_shader3") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Shader (3) support\n");
This->gl_info.supported[NV_TEXTURE_SHADER3] = TRUE;
} else if (strstr(ThisExtn, "GL_NV_vertex_program")) {
This->gl_info.vs_nv_version = max(This->gl_info.vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program1_1")) ? VS_VERSION_11 : VS_VERSION_10);
This->gl_info.vs_nv_version = max(This->gl_info.vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program2")) ? VS_VERSION_20 : VS_VERSION_10);
......
......@@ -533,12 +533,12 @@ void draw_vertex(LPDIRECT3DDEVICE8 iface, /* interf
/* Specular Colour ------------------------------------------*/
if (isSpecular == TRUE) {
#if defined(GL_EXT_secondary_color)
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColor3fvEXT(sRGB));
VTRACE(("glSecondaryColor4f: r,g,b=%f,%f,%f\n", sRGB[0], sRGB[1], sRGB[2]));
} else {
VTRACE(("Specular color extensions not supplied\n"));
}
#endif
}
/* Normal -------------------------------- */
......@@ -794,44 +794,29 @@ void drawStridedFast(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd,
sd->u.s.specular.dwStride,
sd->u.s.specular.lpData));
#if defined(GL_VERSION_1_4)
glSecondaryColorPointer(4, GL_UNSIGNED_BYTE,
sd->u.s.specular.dwStride,
sd->u.s.specular.lpData);
vcheckGLcall("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY)");
#elif defined(GL_EXT_secondary_color)
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE,
sd->u.s.specular.dwStride,
sd->u.s.specular.lpData);
checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
}
#else
vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
} else {
/* Missing specular color is not critical, no warnings */
VTRACE(("Specular colour is not supported in this GL implementation\n"));
#endif
}
} else {
#if defined(GL_VERSION_1_4)
glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY)");
glSecondaryColor3f(0, 0, 0);
checkGLcall("glSecondaryColor3f(0, 0, 0)");
#elif defined(GL_EXT_secondary_color)
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
} else {
/* Missing specular color is not critical, no warnings */
VTRACE(("Specular colour is not supported in this GL implementation\n"));
}
#else
/* Do not worry if specular colour missing and disable request */
#endif
}
/* Texture coords -------------------------------------------*/
......@@ -1187,40 +1172,31 @@ void drawStridedSlow(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd,
if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
#if 1
/* 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 defined(GL_VERSION_1_4)
glSecondaryColor3ub((specularColor >> 16) & 0xFF,
(specularColor >> 8) & 0xFF,
(specularColor >> 0) & 0xFF);
#elif defined(GL_EXT_secondary_color)
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColor3ubEXT)(
(specularColor >> 16) & 0xFF,
(specularColor >> 8) & 0xFF,
(specularColor >> 0) & 0xFF);
}
#else
} else {
/* Do not worry if specular colour missing and disable request */
VTRACE(("Specular color extensions not supplied\n"));
#endif
}
} else {
#if defined(GL_VERSION_1_4)
if (vx_index == 0) glSecondaryColor3f(0, 0, 0);
#elif defined(GL_EXT_secondary_color)
if (vx_index == 0 && GL_SUPPORT(EXT_SECONDARY_COLOR)) {
if (vx_index == 0) {
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
}
#else
} else {
/* Do not worry if specular colour missing and disable request */
#endif
VTRACE(("Specular color extensions not supplied\n"));
}
}
}
#endif
/* Normal -------------------------------- */
if (sd->u.s.normal.lpData != NULL) {
......
......@@ -574,7 +574,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
ENTER_GL();
glCompressedTexImage2D(gl_target,
GL_EXTCALL_DEV(glCompressedTexImage2DARB, This->Device)(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
This->myDesc.Width,
......
......@@ -378,6 +378,7 @@ SHORT D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
/* color buffer */
case D3DFMT_P8: retVal = 1; break;
case D3DFMT_R3G3B2: retVal = 1; break;
case D3DFMT_V8U8: retVal = 2; break;
case D3DFMT_R5G6B5: retVal = 2; break;
case D3DFMT_X1R5G5B5: retVal = 2; break;
case D3DFMT_A4R4G4B4: retVal = 2; break;
......@@ -432,6 +433,7 @@ GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
switch (fmt) {
case D3DFMT_P8: retVal = GL_COLOR_INDEX8_EXT; break;
case D3DFMT_A8P8: retVal = GL_COLOR_INDEX8_EXT; break;
case D3DFMT_V8U8: retVal = GL_COLOR_INDEX8_EXT; break;
case D3DFMT_A4R4G4B4: retVal = GL_RGBA4; break;
case D3DFMT_A8R8G8B8: retVal = GL_RGBA8; break;
......@@ -466,6 +468,7 @@ GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
switch (fmt) {
case D3DFMT_P8: retVal = GL_COLOR_INDEX; break;
case D3DFMT_A8P8: retVal = GL_COLOR_INDEX; break;
case D3DFMT_V8U8: retVal = GL_COLOR_INDEX; break;
case D3DFMT_A4R4G4B4: retVal = GL_BGRA; break;
case D3DFMT_A8R8G8B8: retVal = GL_BGRA; break;
......@@ -501,6 +504,7 @@ GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
switch (fmt) {
case D3DFMT_P8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A8P8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_V8U8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A4R4G4B4: retVal = GL_UNSIGNED_SHORT_4_4_4_4_REV; break;
case D3DFMT_A8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
......@@ -582,18 +586,8 @@ GLenum StencilOp(DWORD op) {
case D3DSTENCILOP_INCRSAT : return GL_INCR;
case D3DSTENCILOP_DECRSAT : return GL_DECR;
case D3DSTENCILOP_INVERT : return GL_INVERT;
#if defined(GL_VERSION_1_4)
case D3DSTENCILOP_INCR : return GL_INCR_WRAP;
case D3DSTENCILOP_DECR : return GL_DECR_WRAP;
#elif defined(GL_EXT_stencil_wrap)
case D3DSTENCILOP_INCR : return GL_INCR_WRAP_EXT;
case D3DSTENCILOP_DECR : return GL_DECR_WRAP_EXT;
#else
case D3DSTENCILOP_INCR : FIXME("Unsupported stencil op D3DSTENCILOP_INCR\n");
return GL_INCR; /* Fixme - needs to support wrap */
case D3DSTENCILOP_DECR : FIXME("Unsupported stencil op D3DSTENCILOP_DECR\n");
return GL_DECR; /* Fixme - needs to support wrap */
#endif
default:
FIXME("Invalid stencil op %ld\n", op);
return GL_ALWAYS;
......@@ -1276,6 +1270,49 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
break;
case D3DTOP_BUMPENVMAP:
{
if (GL_SUPPORT(NV_TEXTURE_SHADER)) {
/*
texture unit 0: GL_TEXTURE_2D
texture unit 1: GL_DOT_PRODUCT_NV
texture unit 2: GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV
texture unit 3: GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV
*/
float m[2][2];
union {
float f;
DWORD d;
} tmpvalue;
tmpvalue.d = This->StateBlock->texture_state[Stage][D3DTSS_BUMPENVMAT00];
m[0][0] = tmpvalue.f;
tmpvalue.d = This->StateBlock->texture_state[Stage][D3DTSS_BUMPENVMAT01];
m[0][1] = tmpvalue.f;
tmpvalue.d = This->StateBlock->texture_state[Stage][D3DTSS_BUMPENVMAT10];
m[1][0] = tmpvalue.f;
tmpvalue.d = This->StateBlock->texture_state[Stage][D3DTSS_BUMPENVMAT11];
m[1][1] = tmpvalue.f;
if (FALSE == This->texture_shader_active) {
This->texture_shader_active = TRUE;
glEnable(GL_TEXTURE_SHADER_NV);
}
/*
glActiveTextureARB(GL_TEXTURE0_ARB + Stage - 1);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
*/
glActiveTextureARB(GL_TEXTURE1_ARB + Stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + Stage - 1);
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, (float*)&m[0]);
break;
}
}
case D3DTOP_BUMPENVMAPLUMINANCE:
default:
Handled = FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment