Don't enable GL_LINE_SMOOTH for AMD GPUs as a workround for lines and circles not being rendered correctly draft
authorS.D.
Tue, 29 Nov 2022 00:49:05 +0200
changeset 15924 3de00d203178
parent 15915 35d26863a88e
Don't enable GL_LINE_SMOOTH for AMD GPUs as a workround for lines and circles not being rendered correctly
hedgewars/uRender.pas
--- a/hedgewars/uRender.pas	Mon Oct 31 02:11:37 2022 +0200
+++ b/hedgewars/uRender.pas	Tue Nov 29 00:49:05 2022 +0200
@@ -135,6 +135,7 @@
     // texture/vertex buffers for left/right/default eye modes
     texLRDtb, texLvb, texRvb: array [0..3] of TVertex2f;
 {$ENDIF}
+   isLineSmoothBroken : boolean;
 
 procedure openglLoadIdentity    (); forward;
 procedure openglTranslProjMatrix(X, Y, Z: GLFloat); forward;
@@ -447,6 +448,8 @@
     // suppress hint/warning
     AuxBufNum:= AuxBufNum;
 
+    isLineSmoothBroken:= shortstring(glGetString(GL_VENDOR)) = 'AMD';
+
     // get the max (h and v) size for textures that the gpu can support
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
     if MaxTextureSize <= 0 then
@@ -1501,7 +1504,8 @@
 
 procedure DrawLineOnScreen(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
 begin
-    glEnable(GL_LINE_SMOOTH);
+    if not isLineSmoothBroken then
+       glEnable(GL_LINE_SMOOTH);
 
     EnableTexture(False);
 
@@ -1519,7 +1523,8 @@
 
     EnableTexture(True);
 
-    glDisable(GL_LINE_SMOOTH);
+    if not isLineSmoothBroken then
+       glDisable(GL_LINE_SMOOTH);
 end;
 
 procedure DrawRect(rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean);
@@ -1590,14 +1595,17 @@
     end;
 
     EnableTexture(False);
-    glEnable(GL_LINE_SMOOTH);
+    if not isLineSmoothBroken then
+       glEnable(GL_LINE_SMOOTH);
+
     //openglPushMatrix;
     glLineWidth(Width);
     SetVertexPointer(@VertexBuffer[0], 60);
     glDrawArrays(GL_LINE_LOOP, 0, 60);
     //openglPopMatrix;
     EnableTexture(True);
-    glDisable(GL_LINE_SMOOTH);
+    if not isLineSmoothBroken then
+       glDisable(GL_LINE_SMOOTH);
 end;
 
 procedure DrawCircleFilled(X, Y, Radius: LongInt; r, g, b, a: Byte);