Commit b02a166c authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Introduce a get_fog_start_end() function.

parent 53ff3279
...@@ -1006,47 +1006,8 @@ void state_fogstartend(struct wined3d_context *context, const struct wined3d_sta ...@@ -1006,47 +1006,8 @@ void state_fogstartend(struct wined3d_context *context, const struct wined3d_sta
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
float fogstart, fogend; float fogstart, fogend;
union {
DWORD d;
float f;
} tmpvalue;
switch(context->fog_source) {
case FOGSOURCE_VS:
fogstart = 1.0f;
fogend = 0.0f;
break;
case FOGSOURCE_COORD:
fogstart = 255.0f;
fogend = 0.0f;
break;
case FOGSOURCE_FFP: get_fog_start_end(context, state, &fogstart, &fogend);
tmpvalue.d = state->render_states[WINED3D_RS_FOGSTART];
fogstart = tmpvalue.f;
tmpvalue.d = state->render_states[WINED3D_RS_FOGEND];
fogend = tmpvalue.f;
/* Special handling for fogstart == fogend. In d3d with vertex
* fog, everything is fogged. With table fog, everything with
* fog_coord < fog_start is unfogged, and fog_coord > fog_start
* is fogged. Windows drivers disagree when fog_coord == fog_start. */
if (state->render_states[WINED3D_RS_FOGTABLEMODE] == WINED3D_FOG_NONE
&& fogstart == fogend)
{
fogstart = -INFINITY;
fogend = 0.0f;
}
break;
default:
/* This should not happen.context->fog_source is set in wined3d, not the app.
* Still this is needed to make the compiler happy
*/
ERR("Unexpected fog coordinate source\n");
fogstart = 0.0f;
fogend = 0.0f;
}
gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, fogstart); gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, fogstart);
checkGLcall("glFogf(GL_FOG_START, fogstart)"); checkGLcall("glFogf(GL_FOG_START, fogstart)");
......
...@@ -3654,6 +3654,51 @@ void get_pointsize(const struct wined3d_context *context, const struct wined3d_s ...@@ -3654,6 +3654,51 @@ void get_pointsize(const struct wined3d_context *context, const struct wined3d_s
*out_pointsize = pointsize.f; *out_pointsize = pointsize.f;
} }
void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
float *start, float *end)
{
union
{
DWORD d;
float f;
} tmpvalue;
switch (context->fog_source)
{
case FOGSOURCE_VS:
*start = 1.0f;
*end = 0.0f;
break;
case FOGSOURCE_COORD:
*start = 255.0f;
*end = 0.0f;
break;
case FOGSOURCE_FFP:
tmpvalue.d = state->render_states[WINED3D_RS_FOGSTART];
*start = tmpvalue.f;
tmpvalue.d = state->render_states[WINED3D_RS_FOGEND];
*end = tmpvalue.f;
/* Special handling for fog_start == fog_end. In d3d with vertex
* fog, everything is fogged. With table fog, everything with
* fog_coord < fog_start is unfogged, and fog_coord > fog_start
* is fogged. Windows drivers disagree when fog_coord == fog_start. */
if (state->render_states[WINED3D_RS_FOGTABLEMODE] == WINED3D_FOG_NONE && *start == *end)
{
*start = -INFINITY;
*end = 0.0f;
}
break;
default:
/* This should not happen, context->fog_source is set in wined3d, not the app. */
ERR("Unexpected fog coordinate source.\n");
*start = 0.0f;
*end = 0.0f;
}
}
/* This small helper function is used to convert a bitmask into the number of masked bits */ /* This small helper function is used to convert a bitmask into the number of masked bits */
unsigned int count_bits(unsigned int mask) unsigned int count_bits(unsigned int mask)
{ {
......
...@@ -3074,6 +3074,8 @@ void get_pointsize_minmax(const struct wined3d_context *context, const struct wi ...@@ -3074,6 +3074,8 @@ void get_pointsize_minmax(const struct wined3d_context *context, const struct wi
float *out_min, float *out_max) DECLSPEC_HIDDEN; float *out_min, float *out_max) DECLSPEC_HIDDEN;
void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state, void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
float *out_pointsize, float *out_att) DECLSPEC_HIDDEN; float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
float *start, float *end) DECLSPEC_HIDDEN;
/* Using additional shader constants (uniforms in GLSL / program environment /* Using additional shader constants (uniforms in GLSL / program environment
* or local parameters in ARB) is costly: * or local parameters in ARB) is costly:
......
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