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

wined3d: A point size fix.

parent 27e8b829
...@@ -1248,19 +1248,6 @@ static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, Win ...@@ -1248,19 +1248,6 @@ static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, Win
} }
} }
static void state_psize(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
union {
DWORD d;
float f;
} tmpvalue;
/* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE];
TRACE("Set point size to %f\n", tmpvalue.f);
glPointSize(tmpvalue.f);
checkGLcall("glPointSize(...);");
}
static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
union { union {
DWORD d; DWORD d;
...@@ -1311,31 +1298,45 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3 ...@@ -1311,31 +1298,45 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
/* Default values */ /* Default values */
GLfloat att[3] = {1.0f, 0.0f, 0.0f}; GLfloat att[3] = {1.0f, 0.0f, 0.0f};
union {
DWORD d;
float f;
} pointSize, A, B, C;
/* pointSize.d = stateblock->renderState[WINED3DRS_POINTSIZE];
* Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f. A.d = stateblock->renderState[WINED3DRS_POINTSCALE_A];
* This means that OpenGL will clamp really small point sizes to 1.0f. B.d = stateblock->renderState[WINED3DRS_POINTSCALE_B];
* To correct for this we need to multiply by the scale factor when sizes C.d = stateblock->renderState[WINED3DRS_POINTSCALE_C];
* are less than 1.0f. scale_factor = 1.0f / point_size.
*/
GLfloat pointSize = *((float*)&stateblock->renderState[WINED3DRS_POINTSIZE]);
if(pointSize > 0.0f) {
GLfloat scaleFactor;
if(pointSize < 1.0f) { if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
scaleFactor = pointSize * pointSize; GLfloat scaleFactor;
float h = stateblock->viewport.Height;
if(pointSize.f < 1.0f) {
/*
* Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f.
* This means that OpenGL will clamp really small point sizes to 1.0f.
* To correct for this we need to multiply by the scale factor when sizes
* are less than 1.0f. scale_factor = 1.0f / point_size.
*/
scaleFactor = pointSize.f;
} else if(pointSize.f > GL_LIMITS(pointsize)) {
/* gl already scales the input to glPointSize,
* d3d scales the result after the point size scale.
* If the point size is bigger than the max size, use the
* scaling to scale it bigger, and set the gl point size to max
*/
scaleFactor = pointSize.f / GL_LIMITS(pointsize);
TRACE("scale: %f\n", scaleFactor);
pointSize.f = GL_LIMITS(pointsize);
} else { } else {
scaleFactor = 1.0f; scaleFactor = 1.0f;
} }
scaleFactor = pow(h * scaleFactor, 2);
if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) { att[0] = A.f / scaleFactor;
att[0] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_A]) / att[1] = B.f / scaleFactor;
(stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor); att[2] = C.f / scaleFactor;
att[1] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_B]) /
(stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
att[2] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_C]) /
(stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
}
} }
if(GL_SUPPORT(ARB_POINT_PARAMETERS)) { if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
...@@ -1345,9 +1346,12 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3 ...@@ -1345,9 +1346,12 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) { else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att); GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ..."); checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...");
} else { } else if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
TRACE("POINT_PARAMETERS not supported in this version of opengl\n"); WARN("POINT_PARAMETERS not supported in this version of opengl\n");
} }
glPointSize(pointSize.f);
checkGLcall("glPointSize(...);");
} }
static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
...@@ -3468,7 +3472,9 @@ static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon ...@@ -3468,7 +3472,9 @@ static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) { if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context); transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
} }
if(!isStateDirty(context, STATE_RENDER(WINED3DRS_POINTSCALEENABLE))) {
state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE), stateblock, context);
}
} }
static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
...@@ -3787,7 +3793,7 @@ const struct StateEntry StateTable[] = ...@@ -3787,7 +3793,7 @@ const struct StateEntry StateTable[] =
{ /*151, WINED3DRS_VERTEXBLEND */ STATE_RENDER(WINED3DRS_VERTEXBLEND), state_vertexblend }, { /*151, WINED3DRS_VERTEXBLEND */ STATE_RENDER(WINED3DRS_VERTEXBLEND), state_vertexblend },
{ /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping }, { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
{ /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl }, { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl },
{ /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSIZE), state_psize }, { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
{ /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin }, { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin },
{ /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite }, { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite },
{ /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale }, { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
......
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