From ce9cfd730f31c101636b3fbe4cb6dc264d85dd0f Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 8 Jul 2026 11:56:09 +0300 Subject: [PATCH] Revert "fix(opengl): use Lazarus OpenGLContext" This reverts commit 004c363df836b0893c3fdbbc9e97a6717aaf27d8. --- MainForm.pas | 5 +++-- SpectrumViewOpengl.pas | 6 ++++-- WaterfallViewOpengl.pas | 20 ++++++++++++++------ WidebandView.pas | 5 +++-- ewsdr.lpi | 2 +- ewsdr.lpr | 2 +- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/MainForm.pas b/MainForm.pas index 5842a2e..6d560dc 100644 --- a/MainForm.pas +++ b/MainForm.pas @@ -25,7 +25,7 @@ uses Classes, SysUtils, StrUtils, FreqDisplay, DeviceForm, VfoOverlay, SampleRateOverlay, BandPlanOverlay, FlatButton, FlatSlider, FlatDropDown, AppTheme, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Buttons, Menus, Math, Types, - OpenGLContext, + OpenGLContextEx, LCLIntf, LCLType, GraphType, HPSDRProtocol, HPSDRNetwork, WDSP, WDSPEngine, AudioOutput, AudioInput, @@ -1004,7 +1004,8 @@ begin FSplitterRatio := 0.40; FSplitterDrag := False; - // Штатный Lazarus OpenGLContext включается только явным ключом --opengl. + // OpenGLContextEx (QOpenGLWidget-бэкенд) работает и в нативном Wayland, + // старая X11-заглушка больше не нужна FUseOpenGLSpectrum := HasOpenGLSpectrumSwitch; if FUseOpenGLSpectrum then FSpecView := TSpectrumViewOpenGL.Create diff --git a/SpectrumViewOpengl.pas b/SpectrumViewOpengl.pas index 4d5b2c2..cb90a53 100644 --- a/SpectrumViewOpengl.pas +++ b/SpectrumViewOpengl.pas @@ -16,7 +16,7 @@ interface uses Classes, SysUtils, Graphics, Controls, Math, Types, - OpenGLContext, GL, + OpenGLContextEx, GL, AppTheme, SpectrumView, VfoOverlay, BandPlanOverlay, WaterfallView, WaterfallViewOpengl; @@ -980,7 +980,9 @@ begin H := FGLControl.Height; if (W <= 0) or (H <= 0) then Exit; - glViewport(0, 0, W, H); + // HiDPI: viewport в физических пикселях FBO, координаты — логические + glViewport(0, 0, Round(W * FGLControl.PixelScale), + Round(H * FGLControl.PixelScale)); glMatrixMode(GL_PROJECTION); glLoadIdentity; glOrtho(0, W, H, 0, -1, 1); diff --git a/WaterfallViewOpengl.pas b/WaterfallViewOpengl.pas index 11597fc..8f5537e 100644 --- a/WaterfallViewOpengl.pas +++ b/WaterfallViewOpengl.pas @@ -15,7 +15,7 @@ interface uses Classes, SysUtils, Graphics, Controls, Math, - OpenGLContext, GL, + OpenGLContextEx, GL, AppTheme, WaterfallView; type @@ -322,8 +322,10 @@ end; procedure TWaterfallViewOpenGL.SetWaterfallBitmapSize(W, H: Integer); begin if (W <= 0) or (H <= 0) then Exit; + // Ширина текстуры — в физических пикселях (HiDPI): строка водопада должна + // ложиться 1:1 на пиксели фреймбуфера, иначе GL размажет её при увеличении. if Assigned(FGLControl) and FGLControl.MakeCurrent then - EnsureTexture(W, H); + EnsureTexture(Round(W * FGLControl.PixelScale), H); FWaterfallDirty := True; end; @@ -334,7 +336,8 @@ end; procedure TWaterfallViewOpenGL.PaintWaterfall(Sender: TObject); var - W, H: Integer; + W, H, TexW: Integer; + Scale: Double; R, G, B: GLFloat; begin if Sender is TOpenGLControl then FGLControl := TOpenGLControl(Sender); @@ -342,7 +345,12 @@ begin W := FGLControl.Width; H := FGLControl.Height; if (W <= 0) or (H <= 0) then Exit; - glViewport(0, 0, W, H); + // HiDPI: viewport покрывает весь FBO (физические пиксели), координаты + // остаются логическими; строка водопада строится в физической ширине. + Scale := FGLControl.PixelScale; + TexW := Round(W * Scale); + + glViewport(0, 0, TexW, Round(H * Scale)); glMatrixMode(GL_PROJECTION); glLoadIdentity; glOrtho(0, W, H, 0, -1, 1); @@ -357,10 +365,10 @@ begin glClearColor(R, G, B, 1); glClear(GL_COLOR_BUFFER_BIT); - EnsureTexture(W, H); + EnsureTexture(TexW, H); if FWaterfallDirty then begin - UploadCurrentRow(W); + UploadCurrentRow(TexW); FWaterfallDirty := False; end; DrawTextureWrapped(W, H); diff --git a/WidebandView.pas b/WidebandView.pas index 3ddf318..520a8e1 100644 --- a/WidebandView.pas +++ b/WidebandView.pas @@ -18,7 +18,7 @@ interface uses Classes, SysUtils, Math, Graphics, Controls, ExtCtrls, - OpenGLContext, GL, AppTheme, WDSP; + OpenGLContextEx, GL, AppTheme, WDSP; type TWidebandView = class @@ -1077,7 +1077,8 @@ begin UploadLabelTextureToGL; FGLBackgroundDirty := False; end; - glViewport(0, 0, W, H); + // HiDPI: viewport в физических пикселях FBO, координаты — логические + glViewport(0, 0, Round(W * C.PixelScale), Round(H * C.PixelScale)); glMatrixMode(GL_PROJECTION); glLoadIdentity; glOrtho(0, W, 0, H, -1, 1); diff --git a/ewsdr.lpi b/ewsdr.lpi index 0b3b6b3..61aea45 100644 --- a/ewsdr.lpi +++ b/ewsdr.lpi @@ -141,7 +141,7 @@ - + diff --git a/ewsdr.lpr b/ewsdr.lpr index fe2c468..317be48 100644 --- a/ewsdr.lpr +++ b/ewsdr.lpr @@ -15,7 +15,7 @@ uses {$ENDIF} Interfaces, // LCL platform WindowsDPI, - Forms, LazOpenGLContext, + Forms, LazOpenGLContextEx, MainForm, AudioOutput, DeviceForm, FlatButton, FreqDisplay, VfoOverlay, WDSP, WDSPEngine, WebPageHtml, WebServer, WebUtils, WinFirewall, WsClient, Settings, RadioController;