Don't enable GL_LINE_SMOOTH for AMD GPUs as a workround for lines and circles not being rendered correctly
--- 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);