Commit d20768c1 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Support shininess > 128 if opengl does.

parent 73ba896e
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
......
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