mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-02 19:24:46 +01:00
openglcontrol: added Red,Green,Blue bits for target gtk
git-svn-id: trunk@40229 -
This commit is contained in:
parent
043dd66828
commit
14423ccd1a
@ -149,7 +149,8 @@ function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
const MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal;
|
||||
const RedBits, GreenBits, BlueBits,
|
||||
MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal;
|
||||
const AParams: TCreateParams): HWND;
|
||||
procedure LOpenGLDestroyContextInfo(AWinControl: TWinControl);
|
||||
|
||||
@ -157,8 +158,9 @@ procedure LOpenGLDestroyContextInfo(AWinControl: TWinControl);
|
||||
Note that if MultiSampling is > 1, it is expected that caller
|
||||
already checked that GLX_ARB_multisample is available. }
|
||||
function CreateOpenGLContextAttrList(DoubleBuffered: boolean;
|
||||
RGBA: boolean;
|
||||
const MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal): PInteger;
|
||||
RGBA: boolean;
|
||||
const RedBits, GreenBits, BlueBits,
|
||||
MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal): PInteger;
|
||||
|
||||
implementation
|
||||
|
||||
@ -830,7 +832,8 @@ end;
|
||||
function LOpenGLCreateContextCore(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
const MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal;
|
||||
const RedBits, GreenBits, BlueBits,
|
||||
MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal;
|
||||
const AParams: TCreateParams): HWND;
|
||||
var
|
||||
NewWidget: PGtkWidget;
|
||||
@ -838,8 +841,8 @@ var
|
||||
AttrList: PInteger;
|
||||
begin
|
||||
if WSPrivate=nil then ;
|
||||
AttrList:=CreateOpenGLContextAttrList(DoubleBuffered,RGBA,MultiSampling,
|
||||
AlphaBits,DepthBits,StencilBits,AUXBuffers);
|
||||
AttrList:=CreateOpenGLContextAttrList(DoubleBuffered,RGBA,RedBits,GreenBits,
|
||||
BlueBits,MultiSampling,AlphaBits,DepthBits,StencilBits,AUXBuffers);
|
||||
try
|
||||
if SharedControl<>nil then begin
|
||||
SharedArea:={%H-}PGtkGLArea(PtrUInt(SharedControl.Handle));
|
||||
@ -866,7 +869,8 @@ end;
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
const MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal;
|
||||
const RedBits, GreenBits, BlueBits,
|
||||
MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal;
|
||||
const AParams: TCreateParams): HWND;
|
||||
begin
|
||||
if (MultiSampling > 1) and
|
||||
@ -879,16 +883,19 @@ begin
|
||||
{$ENDIF} then
|
||||
try
|
||||
Result := LOpenGLCreateContextCore(AWinControl, WSPrivate, SharedControl,
|
||||
DoubleBuffered, RGBA, MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers, AParams);
|
||||
DoubleBuffered, RGBA, RedBits, GreenBits, BlueBits, MultiSampling,
|
||||
AlphaBits, DepthBits, StencilBits, AUXBuffers, AParams);
|
||||
except
|
||||
{ retry without MultiSampling }
|
||||
Result := LOpenGLCreateContextCore(AWinControl, WSPrivate, SharedControl,
|
||||
DoubleBuffered, RGBA, 1, AlphaBits, DepthBits, StencilBits, AUXBuffers, AParams);
|
||||
DoubleBuffered, RGBA, RedBits, GreenBits, BlueBits, 1, AlphaBits,
|
||||
DepthBits, StencilBits, AUXBuffers, AParams);
|
||||
end else
|
||||
{ no multi-sampling requested (or GLX_ARB_multisample not available),
|
||||
just pass to LOpenGLCreateContextCore }
|
||||
Result := LOpenGLCreateContextCore(AWinControl, WSPrivate, SharedControl,
|
||||
DoubleBuffered, RGBA, MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers, AParams);
|
||||
DoubleBuffered, RGBA, RedBits, GreenBits, BlueBits, MultiSampling,
|
||||
AlphaBits, DepthBits, StencilBits, AUXBuffers, AParams);
|
||||
end;
|
||||
|
||||
procedure LOpenGLDestroyContextInfo(AWinControl: TWinControl);
|
||||
@ -898,7 +905,8 @@ begin
|
||||
end;
|
||||
|
||||
function CreateOpenGLContextAttrList(DoubleBuffered: boolean; RGBA: boolean;
|
||||
const MultiSampling, AlphaBits, DepthBits, StencilBits, AUXBuffers: Cardinal): PInteger;
|
||||
const RedBits, GreenBits, BlueBits, MultiSampling, AlphaBits, DepthBits,
|
||||
StencilBits, AUXBuffers: Cardinal): PInteger;
|
||||
var
|
||||
p: integer;
|
||||
UseFBConfig: boolean;
|
||||
@ -924,9 +932,9 @@ var
|
||||
if not UseFBConfig then Add(GLX_RGBA);
|
||||
{ For UseFBConfig, glXChooseFBConfig already defaults to RGBA }
|
||||
end;
|
||||
Add(GLX_RED_SIZE); Add(1);
|
||||
Add(GLX_GREEN_SIZE); Add(1);
|
||||
Add(GLX_BLUE_SIZE); Add(1);
|
||||
Add(GLX_RED_SIZE); Add(RedBits);
|
||||
Add(GLX_GREEN_SIZE); Add(GreenBits);
|
||||
Add(GLX_BLUE_SIZE); Add(BlueBits);
|
||||
if AlphaBits>0 then
|
||||
begin
|
||||
Add(GLX_ALPHA_SIZE); Add(AlphaBits);
|
||||
|
||||
@ -65,9 +65,11 @@ uses
|
||||
Graphics, LMessages, WSLCLClasses, WSControls,
|
||||
{$IFDEF UseGtkGLX}
|
||||
GLGtkGlxContext;
|
||||
{$DEFINE HasRGBBits}
|
||||
{$ENDIF}
|
||||
{$IFDEF UseGtk2GLX}
|
||||
GLGtkGlxContext;
|
||||
{$DEFINE HasRGBBits}
|
||||
{$ENDIF}
|
||||
{$IFDEF UseCarbonAGL}
|
||||
GLCarbonAGLContext;
|
||||
@ -79,6 +81,8 @@ uses
|
||||
GLQTContext;
|
||||
{$ENDIF}
|
||||
|
||||
const
|
||||
DefaultDepthBits = 16;
|
||||
|
||||
type
|
||||
TOpenGlCtrlMakeCurrentEvent = procedure(Sender: TObject;
|
||||
@ -109,6 +113,9 @@ type
|
||||
FCurrentFrameTime: integer; // in msec
|
||||
FLastFrameTime: integer; // in msec
|
||||
FRGBA: boolean;
|
||||
{$IFDEF HasRGBBits}
|
||||
FRedBits, FGreenBits, FBlueBits,
|
||||
{$ENDIF}
|
||||
FMultiSampling, FAlphaBits, FDepthBits, FStencilBits, FAUXBuffers: Cardinal;
|
||||
FSharedOpenGLControl: TCustomOpenGLControl;
|
||||
FSharingOpenGlControls: TList;
|
||||
@ -116,6 +123,11 @@ type
|
||||
procedure SetAutoResizeViewport(const AValue: boolean);
|
||||
procedure SetDoubleBuffered(const AValue: boolean);
|
||||
procedure SetRGBA(const AValue: boolean);
|
||||
{$IFDEF HasRGBBits}
|
||||
procedure SetRedBits(const AValue: Cardinal);
|
||||
procedure SetGreenBits(const AValue: Cardinal);
|
||||
procedure SetBlueBits(const AValue: Cardinal);
|
||||
{$ENDIF}
|
||||
procedure SetMultiSampling(const AMultiSampling: Cardinal);
|
||||
procedure SetAlphaBits(const AValue: Cardinal);
|
||||
procedure SetDepthBits(const AValue: Cardinal);
|
||||
@ -151,7 +163,11 @@ type
|
||||
write SetAutoResizeViewport default false;
|
||||
property DoubleBuffered: boolean read FDoubleBuffered write SetDoubleBuffered default true;
|
||||
property RGBA: boolean read FRGBA write SetRGBA default true;
|
||||
|
||||
{$IFDEF HasRGBBits}
|
||||
property RedBits: Cardinal read FRedBits write SetRedBits default 8;
|
||||
property GreenBits: Cardinal read FGreenBits write SetGreenBits default 8;
|
||||
property BlueBits: Cardinal read FBlueBits write SetBlueBits default 8;
|
||||
{$ENDIF}
|
||||
{ Number of samples per pixel, for OpenGL multi-sampling (anti-aliasing).
|
||||
|
||||
Value <= 1 means that we use 1 sample per pixel, which means no anti-aliasing.
|
||||
@ -166,7 +182,7 @@ type
|
||||
property MultiSampling: Cardinal read FMultiSampling write SetMultiSampling default 1;
|
||||
|
||||
property AlphaBits: Cardinal read FAlphaBits write SetAlphaBits default 0;
|
||||
property DepthBits: Cardinal read FDepthBits write SetDepthBits default 16;
|
||||
property DepthBits: Cardinal read FDepthBits write SetDepthBits default DefaultDepthBits;
|
||||
property StencilBits: Cardinal read FStencilBits write SetStencilBits default 0;
|
||||
property AUXBuffers: Cardinal read FAUXBuffers write SetAUXBuffers default 0;
|
||||
end;
|
||||
@ -180,6 +196,11 @@ type
|
||||
property AutoResizeViewport;
|
||||
property BorderSpacing;
|
||||
property Enabled;
|
||||
{$IFDEF HasRGBBits}
|
||||
property RedBits;
|
||||
property GreenBits;
|
||||
property BlueBits;
|
||||
{$ENDIF}
|
||||
property MultiSampling;
|
||||
property AlphaBits;
|
||||
property DepthBits;
|
||||
@ -270,6 +291,29 @@ begin
|
||||
OpenGLAttributesChanged;
|
||||
end;
|
||||
|
||||
{$IFDEF HasRGBBits}
|
||||
procedure TCustomOpenGLControl.SetRedBits(const AValue: Cardinal);
|
||||
begin
|
||||
if FRedBits=AValue then exit;
|
||||
FRedBits:=AValue;
|
||||
OpenGLAttributesChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomOpenGLControl.SetGreenBits(const AValue: Cardinal);
|
||||
begin
|
||||
if FGreenBits=AValue then exit;
|
||||
FGreenBits:=AValue;
|
||||
OpenGLAttributesChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomOpenGLControl.SetBlueBits(const AValue: Cardinal);
|
||||
begin
|
||||
if FBlueBits=AValue then exit;
|
||||
FBlueBits:=AValue;
|
||||
OpenGLAttributesChanged;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TCustomOpenGLControl.SetMultiSampling(const AMultiSampling: Cardinal);
|
||||
begin
|
||||
if FMultiSampling=AMultiSampling then exit;
|
||||
@ -297,12 +341,14 @@ begin
|
||||
FStencilBits:=AValue;
|
||||
OpenGLAttributesChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomOpenGLControl.SetAUXBuffers(const AValue: Cardinal);
|
||||
begin
|
||||
if FAUXBuffers=AValue then exit;
|
||||
FAUXBuffers:=AValue;
|
||||
OpenGLAttributesChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomOpenGLControl.SetSharedControl(
|
||||
const AValue: TCustomOpenGLControl);
|
||||
begin
|
||||
@ -391,8 +437,13 @@ begin
|
||||
inherited Create(TheOwner);
|
||||
FDoubleBuffered:=true;
|
||||
FRGBA:=true;
|
||||
{$IFDEF HasRGBBits}
|
||||
FRedBits:=8;
|
||||
FGreenBits:=8;
|
||||
FBlueBits:=8;
|
||||
{$ENDIF}
|
||||
FMultiSampling:=1;
|
||||
FDepthBits:=16;
|
||||
FDepthBits:=DefaultDepthBits;
|
||||
ControlStyle:=ControlStyle-[csSetCaption];
|
||||
if (csDesigning in ComponentState) then begin
|
||||
FCanvas := TControlCanvas.Create;
|
||||
@ -534,6 +585,11 @@ begin
|
||||
Result:=LOpenGLCreateContext(OpenGlControl,WSPrivate,
|
||||
OpenGlControl.SharedControl,
|
||||
AttrControl.DoubleBuffered,AttrControl.RGBA,
|
||||
{$IFDEF HasRGBBits}
|
||||
AttrControl.RedBits,
|
||||
AttrControl.GreenBits,
|
||||
AttrControl.BlueBits,
|
||||
{$ENDIF}
|
||||
AttrControl.MultiSampling,
|
||||
AttrControl.AlphaBits,
|
||||
AttrControl.DepthBits,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user