mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-18 02:41:39 +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 LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||||
|
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||||
procedure LOpenGLClip(Handle: HWND);
|
procedure LOpenGLClip(Handle: HWND);
|
||||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||||
{%H-}WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
{%H-}WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||||
@ -82,6 +83,11 @@ begin
|
|||||||
Result:=aglSetCurrentContext(AGLContext)<>0;
|
Result:=aglSetCurrentContext(AGLContext)<>0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||||
|
begin
|
||||||
|
Result := aglSetCurrentContext(nil)<>GL_FALSE;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure LOpenGLClip(Handle: HWND);
|
procedure LOpenGLClip(Handle: HWND);
|
||||||
var
|
var
|
||||||
AGLContext: TAGLContext;
|
AGLContext: TAGLContext;
|
||||||
|
@ -157,6 +157,7 @@ function gdk_x11_get_default_screen:gint;cdecl;external;
|
|||||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||||
|
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||||
DoubleBuffered, RGBA: boolean;
|
DoubleBuffered, RGBA: boolean;
|
||||||
@ -907,6 +908,15 @@ begin
|
|||||||
Result:=gtk_gl_area_make_current(glarea);
|
Result:=gtk_gl_area_make_current(glarea);
|
||||||
end;
|
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}
|
{$IFDEF LCLGtk2}
|
||||||
function gtkglarea_size_allocateCB(Widget: PGtkWidget; Size: pGtkAllocation;
|
function gtkglarea_size_allocateCB(Widget: PGtkWidget; Size: pGtkAllocation;
|
||||||
Data: gPointer): GBoolean; cdecl;
|
Data: gPointer): GBoolean; cdecl;
|
||||||
|
@ -62,6 +62,7 @@ type
|
|||||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||||
|
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||||
DoubleBuffered, RGBA: boolean;
|
DoubleBuffered, RGBA: boolean;
|
||||||
@ -177,6 +178,20 @@ begin
|
|||||||
Widget.glxcontext));
|
Widget.glxcontext));
|
||||||
end;
|
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;
|
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||||
DoubleBuffered, RGBA: boolean;
|
DoubleBuffered, RGBA: boolean;
|
||||||
|
@ -20,6 +20,7 @@ uses
|
|||||||
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
procedure LOpenGLViewport(Left, Top, Width, Height: integer);
|
||||||
procedure LOpenGLSwapBuffers(Handle: HWND);
|
procedure LOpenGLSwapBuffers(Handle: HWND);
|
||||||
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
function LOpenGLMakeCurrent(Handle: HWND): boolean;
|
||||||
|
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||||
DoubleBuffered, RGBA: boolean;
|
DoubleBuffered, RGBA: boolean;
|
||||||
@ -246,6 +247,11 @@ begin
|
|||||||
Result:=wglMakeCurrent(Info^.DC,Info^.WGLContext);
|
Result:=wglMakeCurrent(Info^.DC,Info^.WGLContext);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function LOpenGLReleaseContext(Handle: HWND): boolean;
|
||||||
|
begin
|
||||||
|
Result:=wglMakeCurrent(0,0);
|
||||||
|
end;
|
||||||
|
|
||||||
function GlWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
function GlWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||||
LParam: Windows.LParam): LResult; stdcall;
|
LParam: Windows.LParam): LResult; stdcall;
|
||||||
var
|
var
|
||||||
|
@ -148,6 +148,7 @@ type
|
|||||||
procedure DoOnPaint; virtual;
|
procedure DoOnPaint; virtual;
|
||||||
procedure SwapBuffers; virtual;
|
procedure SwapBuffers; virtual;
|
||||||
function MakeCurrent(SaveOldToStack: boolean = false): boolean; virtual;
|
function MakeCurrent(SaveOldToStack: boolean = false): boolean; virtual;
|
||||||
|
function ReleaseContext: boolean; virtual;
|
||||||
function RestoreOldOpenGLControl: boolean;
|
function RestoreOldOpenGLControl: boolean;
|
||||||
function SharingControlCount: integer;
|
function SharingControlCount: integer;
|
||||||
property SharingControls[Index: integer]: TCustomOpenGLControl read GetSharingControls;
|
property SharingControls[Index: integer]: TCustomOpenGLControl read GetSharingControls;
|
||||||
@ -548,6 +549,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomOpenGLControl.ReleaseContext: boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if not HandleAllocated then exit;
|
||||||
|
Result:=LOpenGLReleaseContext(Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomOpenGLControl.RestoreOldOpenGLControl: boolean;
|
function TCustomOpenGLControl.RestoreOldOpenGLControl: boolean;
|
||||||
var
|
var
|
||||||
RestoredControl: TCustomOpenGLControl;
|
RestoredControl: TCustomOpenGLControl;
|
||||||
|
Loading…
Reference in New Issue
Block a user