mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-14 21:36:18 +02:00
OpenGLControl: Implement release context method. Issue #24925, patch from Anton Kavalenka
git-svn-id: trunk@42582 -
This commit is contained in:
parent
708b2f4a5d
commit
0709051eff
@ -24,6 +24,7 @@ uses
|
||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
procedure LOpenGLClip(Handle: HWND);
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
{%H-}WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
@ -82,6 +83,11 @@ begin
|
||||
Result:=aglSetCurrentContext(AGLContext)<>0;
|
||||
end;
|
||||
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
begin
|
||||
Result := aglSetCurrentContext(nil)<>GL_FALSE;
|
||||
end;
|
||||
|
||||
procedure LOpenGLClip(Handle: HWND);
|
||||
var
|
||||
AGLContext: TAGLContext;
|
||||
|
@ -157,6 +157,7 @@ function gdk_x11_get_default_screen:gint;cdecl;external;
|
||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
@ -907,6 +908,15 @@ begin
|
||||
Result:=gtk_gl_area_make_current(glarea);
|
||||
end;
|
||||
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
var pd:PDIsplay;
|
||||
begin
|
||||
Result := false;
|
||||
pd := glXGetCurrentDisplay();
|
||||
if Assigned(pd) then
|
||||
Result := glXMakeCurrent(pd, 0, nil);
|
||||
end;
|
||||
|
||||
{$IFDEF LCLGtk2}
|
||||
function gtkglarea_size_allocateCB(Widget: PGtkWidget; Size: pGtkAllocation;
|
||||
Data: gPointer): GBoolean; cdecl;
|
||||
|
@ -62,6 +62,7 @@ type
|
||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
@ -177,6 +178,20 @@ begin
|
||||
Widget.glxcontext));
|
||||
end;
|
||||
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
var
|
||||
Widget: TQtGLWidget;
|
||||
begin
|
||||
Result := false;
|
||||
if Handle=0 then
|
||||
RaiseGDBException('LOpenGLSwapBuffers Handle=0');
|
||||
|
||||
Widget:=TQtGLWidget(Handle);
|
||||
Result := glXMakeCurrent(Widget.xdisplay, 0, nil);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
|
@ -20,6 +20,7 @@ uses
|
||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||
DoubleBuffered, RGBA: boolean;
|
||||
@ -246,6 +247,11 @@ begin
|
||||
Result:=wglMakeCurrent(Info^.DC,Info^.WGLContext);
|
||||
end;
|
||||
|
||||
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||
begin
|
||||
Result:=wglMakeCurrent(0,0);
|
||||
end;
|
||||
|
||||
function GlWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||
LParam: Windows.LParam): LResult; stdcall;
|
||||
var
|
||||
|
@ -148,6 +148,7 @@ type
|
||||
procedure DoOnPaint; virtual;
|
||||
procedure SwapBuffers; virtual;
|
||||
function MakeCurrent(SaveOldToStack: boolean = false): boolean; virtual;
|
||||
function ReleaseContext: boolean; virtual;
|
||||
function RestoreOldOpenGLControl: boolean;
|
||||
function SharingControlCount: integer;
|
||||
property SharingControls[Index: integer]: TCustomOpenGLControl read GetSharingControls;
|
||||
@ -548,6 +549,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomOpenGLControl.ReleaseContext: boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if not HandleAllocated then exit;
|
||||
Result:=LOpenGLReleaseContext(Handle);
|
||||
end;
|
||||
|
||||
function TCustomOpenGLControl.RestoreOldOpenGLControl: boolean;
|
||||
var
|
||||
RestoredControl: TCustomOpenGLControl;
|
||||
|
Loading…
Reference in New Issue
Block a user