wined3d: Introduce a get_fog_start_end() function.
This commit is contained in:
parent
53ff3279e4
commit
b02a166cc8
|
@ -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;
|
||||
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:
|
||||
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;
|
||||
}
|
||||
get_fog_start_end(context, state, &fogstart, &fogend);
|
||||
|
||||
gl_info->gl_ops.gl.p_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
|
|||
*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 */
|
||||
unsigned int count_bits(unsigned int mask)
|
||||
{
|
||||
|
|
|
@ -3074,6 +3074,8 @@ void get_pointsize_minmax(const struct wined3d_context *context, const struct wi
|
|||
float *out_min, float *out_max) DECLSPEC_HIDDEN;
|
||||
void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
|
||||
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
|
||||
* or local parameters in ARB) is costly:
|
||||
|
|
Loading…
Reference in New Issue