From d20768c12028b4e6671b80e06bb4917fcc758479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 2 Mar 2008 00:02:18 +0100 Subject: [PATCH] wined3d: Support shininess > 128 if opengl does. --- dlls/wined3d/directx.c | 6 ++++++ dlls/wined3d/state.c | 13 +++++++------ include/wine/wined3d_gl.h | 9 +++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 3d819f144a5..2e85eba5595 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -128,6 +128,7 @@ static const struct { {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 }, {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 }, {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 }, + {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 }, /* SGI */ {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 }, @@ -955,6 +956,11 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { } else if (gl_info->supported[NV_FRAGMENT_PROGRAM]) { gl_info->ps_nv_version = PS_VERSION_20; } + if (gl_info->supported[NV_LIGHT_MAX_EXPONENT]) { + glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->max_shininess); + } else { + gl_info->max_shininess = 128.0; + } if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) { /* If we have full NP2 texture support, disable GL_ARB_texture_rectangle because we will never use it. * This saves a few redundant glDisable calls diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 4dff4c0fba7..616b28f37a3 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -664,14 +664,15 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular); checkGLcall("glMaterialfv"); - if(stateblock->material.Power > 128.0) { + if(stateblock->material.Power > GL_LIMITS(shininess)) { /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0 - * and 128.0, although in d3d neither -1 nor 129 produce an error. For values > 128 clamp - * them, since 128 results in a hardly visible specular highlight, so it should be safe to - * to clamp to 128 + * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent + * allows bigger values. If the extension is supported, GL_LIMITS(shininess) contains the + * value reported by the extension, otherwise 128. For values > GL_LIMITS(shininess) clamp + * them, it should be safe to do so without major visual dissortions. */ - WARN("Material power > 128\n"); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 128.0); + WARN("Material power = %f, limit %f\n", stateblock->material.Power, GL_LIMITS(shininess)); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, GL_LIMITS(shininess)); } else { glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->material.Power); } diff --git a/include/wine/wined3d_gl.h b/include/wine/wined3d_gl.h index ac1457f2e18..1e45b200565 100644 --- a/include/wine/wined3d_gl.h +++ b/include/wine/wined3d_gl.h @@ -2913,6 +2913,13 @@ typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params); #endif +/* GL_NV_light_max_exponent */ +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + /* GL_VERSION_2_0 */ #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 @@ -3267,6 +3274,7 @@ typedef enum _GL_SupportedExt { NV_VERTEX_PROGRAM3, NV_FENCE, NV_DEPTH_CLAMP, + NV_LIGHT_MAX_EXPONENT, /* ATI */ ATI_SEPARATE_STENCIL, ATI_TEXTURE_ENV_COMBINE3, @@ -3722,6 +3730,7 @@ typedef struct _WineD3D_GL_Info { UINT max_anisotropy; UINT max_aux_buffers; UINT max_glsl_varyings; + float max_shininess; unsigned max_vshader_constantsF; unsigned max_pshader_constantsF;