Browse Source

* [glcContext] implemented share context for gtk2/glx

master
bergmann89 8 years ago
parent
commit
2d9ca0694c
1 changed files with 25 additions and 14 deletions
  1. +25
    -14
      uglcContextGtk2GLX.pas

+ 25
- 14
uglcContextGtk2GLX.pas View File

@@ -36,8 +36,14 @@ type
protected
procedure OpenContext; override;
public
constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings); override; overload;
constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings; const aVersionSettings: TglcContextVersionSettings); override; overload;
constructor Create(const aControl: TWinControl;
const aPixelFormatSettings: TglcContextPixelFormatSettings;
const aShareContext: TglcContext = nil); overload; override;
constructor Create(const aControl: TWinControl;
const aPixelFormatSettings: TglcContextPixelFormatSettings;
const aVersionSettings: TglcContextVersionSettings;
const aShareContext: TglcContext = nil); overload; override;
destructor Destroy; override;
procedure CloseContext; override;
@@ -46,7 +52,6 @@ type
function IsActive: boolean; override;
procedure SwapBuffers; override;
procedure SetSwapInterval(const aInterval: GLint); override;
procedure Share(const aContext: TglcContext); override;
class function ChangeDisplaySettings(const aWidth, aHeight,
aBitPerPixel, aFreq: Integer; const aFlags: TglcDisplayFlags): Boolean; override;
@@ -420,6 +425,7 @@ end;
procedure TglcContextGtk2GLX.OpenContext;
var
share: GLXContext;
Attribs: array of GLint;
tmpContext: GLXContext;
glxID: GLXDrawable;
@@ -429,7 +435,14 @@ begin
if not Assigned(FVisual) then
raise EGLXError.Create('Failed to find Visual');
tmpContext := glXCreateContext(FDisplay, FVisual, nil, true);
share := nil;
if Assigned(ShareContext) then begin
if (ShareContext.ClassName <> ClassName) then
raise Exception.Create('share context has invalid type: ' + ShareContext.ClassName);
share := (ShareContext as TglcContextGtk2GLX).FContext;
end;
tmpContext := glXCreateContext(FDisplay, FVisual, share, true);
if fUseVersion and
(fVersionSettings.Major <> GLC_CONTEXT_VERSION_UNKNOWN) and
(fVersionSettings.Minor <> GLC_CONTEXT_VERSION_UNKNOWN) then
@@ -461,7 +474,7 @@ begin
glXDestroyContext(FDisplay, tmpContext);
raise Exception.Create('GLX_ARB_create_context not supported');
end;
FContext := glXCreateContextAttribsARB(FDisplay, FVisual, nil, true, @Attribs[0]);
FContext := glXCreateContextAttribsARB(FDisplay, FVisual, share, true, @Attribs[0]);
glXDestroyContext(FDisplay, tmpContext);
end else
@@ -472,17 +485,19 @@ begin
end;
constructor TglcContextGtk2GLX.Create(const aControl: TWinControl;
const aPixelFormatSettings: TglcContextPixelFormatSettings);
const aPixelFormatSettings: TglcContextPixelFormatSettings;
const aShareContext: TglcContext);
begin
inherited Create(aControl, aPixelFormatSettings);
inherited Create(aControl, aPixelFormatSettings, aShareContext);
UpdateVisual(aControl);
end;
constructor TglcContextGtk2GLX.Create(const aControl: TWinControl;
const aPixelFormatSettings: TglcContextPixelFormatSettings;
const aVersionSettings: TglcContextVersionSettings);
const aVersionSettings: TglcContextVersionSettings;
const aShareContext: TglcContext);
begin
inherited Create(aControl, aPixelFormatSettings, aVersionSettings);
inherited Create(aControl, aPixelFormatSettings, aVersionSettings, aShareContext);
UpdateVisual(aControl);
end;
@@ -513,6 +528,7 @@ begin
// make current
glxID := GDK_DRAWABLE_XID(GTK_WIDGET(FWidget)^.window);
glXMakeCurrent(FDisplay, glxID, FContext);
inherited Activate;
end;
procedure TglcContextGtk2GLX.Deactivate;
@@ -552,11 +568,6 @@ begin
glXSwapIntervalEXT(FDisplay, GDK_WINDOW_XWINDOW(drawable), aInterval);
end;
procedure TglcContextGtk2GLX.Share(const aContext: TglcContext);
begin
raise Exception.Create('not yet implemented');
end;
class function TglcContextGtk2GLX.{%H-}ChangeDisplaySettings(const aWidth, aHeight,
aBitPerPixel, aFreq: Integer; const aFlags: TglcDisplayFlags): Boolean;
begin


Loading…
Cancel
Save