Implements PolygonOffset
TRAC #11719
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch

Author:    Shannon Woods

git-svn-id: https://angleproject.googlecode.com/svn/trunk@208 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index cdfa7c0..d8ca70b 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -1382,7 +1382,18 @@
 
     if (polygonOffsetFill)
     {
-        UNIMPLEMENTED();   // FIXME
+        gl::Depthbuffer *depthbuffer = getFramebuffer()->getDepthbuffer();
+        if (depthbuffer)
+        {
+            device->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *((DWORD*)&polygonOffsetFactor));
+            float depthBias = ldexp(polygonOffsetUnits, -(int)(depthbuffer->getDepthSize()));
+            device->SetRenderState(D3DRS_DEPTHBIAS, *((DWORD*)&depthBias));
+        }
+    }
+    else
+    {
+        device->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, 0);
+        device->SetRenderState(D3DRS_DEPTHBIAS, 0);
     }
 
     if (sampleAlphaToCoverage)