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