mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 11:39:19 +02:00
OpenGL component: fixed #0009775: OpenGLContext fails to compile under Carbon
git-svn-id: trunk@12331 -
This commit is contained in:
parent
e2e7a99c22
commit
90b32a9139
@ -83,32 +83,19 @@ var
|
|||||||
disp: GDHandle;
|
disp: GDHandle;
|
||||||
aglPixFmt: TAGLPixelFormat;
|
aglPixFmt: TAGLPixelFormat;
|
||||||
aglContext: TAGLContext;
|
aglContext: TAGLContext;
|
||||||
ACarbonWindow: WindowRef;
|
Control: TCarbonCustomControl;
|
||||||
CFString: CFStringRef;
|
|
||||||
Control: ControlRef;
|
|
||||||
R: FPCMacOSAll.Rect;
|
|
||||||
Info: PWidgetInfo;
|
|
||||||
ParentWindow: WindowPtr;
|
|
||||||
AttrList: PInteger;
|
AttrList: PInteger;
|
||||||
|
C: TCreateParams;
|
||||||
begin
|
begin
|
||||||
if AWinControl.Parent=nil then
|
if AWinControl.Parent=nil then
|
||||||
RaiseGDBException('GLCarbonAGLContext.LOpenGLCreateContext no parent');
|
RaiseGDBException('GLCarbonAGLContext.LOpenGLCreateContext no parent');
|
||||||
ParentWindow:=WindowRef(AWinControl.Parent.Handle);
|
|
||||||
|
|
||||||
// create a dummy control
|
C.X := AWinControl.Left;
|
||||||
R:=GetCarbonRect(AWinControl.BoundsRect);
|
C.Y := AWinControl.Top;
|
||||||
Control:=nil;
|
C.Width := AWinControl.Width;
|
||||||
CFString := CFStringCreateWithCString(nil, Pointer(PChar('SubControl')),
|
C.Height := AWinControl.Height;
|
||||||
kCFStringEncodingUTF8);
|
// create a custom control
|
||||||
if CreatePushButtonControl(ParentWindow, R, CFString, Control) <> noErr
|
Control := TCarbonCustomControl.Create(AWinControl, C);
|
||||||
then
|
|
||||||
debugln('CreatePushButtonControl failed');
|
|
||||||
CFRelease(Pointer(CFString));
|
|
||||||
|
|
||||||
// create LCL WidgetInfo
|
|
||||||
Result:=HWnd(Control);
|
|
||||||
Info := CreateWidgetInfo(Control, AWinControl, cwtControlRef);
|
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
|
||||||
|
|
||||||
// create the AGL context
|
// create the AGL context
|
||||||
disp := GetMainDevice ();
|
disp := GetMainDevice ();
|
||||||
@ -120,12 +107,12 @@ begin
|
|||||||
|
|
||||||
// use the carbon window.
|
// use the carbon window.
|
||||||
// TODO: find a way to use only the control for the context
|
// TODO: find a way to use only the control for the context
|
||||||
ACarbonWindow:=WindowRef(GetParentForm(AWinControl).Handle);
|
aglSetDrawable(aglContext,
|
||||||
aglSetDrawable(aglContext,GetWindowPort(ACarbonWindow));
|
GetWindowPort(TCarbonWindow(GetParentForm(AWinControl).Handle).Widget));
|
||||||
|
|
||||||
AGLControlInfo_FOURCC := MakeFourCC('ACI ');
|
AGLControlInfo_FOURCC := MakeFourCC('ACI ');
|
||||||
|
|
||||||
CreateAGLControlInfo(Control,AGLContext);
|
CreateAGLControlInfo(Control.Widget, AGLContext);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LOpenGLDestroyContextInfo(AWinControl: TWinControl);
|
procedure LOpenGLDestroyContextInfo(AWinControl: TWinControl);
|
||||||
@ -134,11 +121,11 @@ var
|
|||||||
Info: PAGLControlInfo;
|
Info: PAGLControlInfo;
|
||||||
begin
|
begin
|
||||||
if not AWinControl.HandleAllocated then exit;
|
if not AWinControl.HandleAllocated then exit;
|
||||||
Ref:=ControlRef(AWinControl.Handle);
|
Ref := ControlRef(TCarbonControl(AWinControl.Handle).Widget);
|
||||||
Info:=GetAGLControlInfo(Ref);
|
Info := GetAGLControlInfo(Ref);
|
||||||
if Info=nil then exit;
|
if Info=nil then exit;
|
||||||
aglDestroyContext(Info^.AGLContext);
|
aglDestroyContext(Info^.AGLContext);
|
||||||
Info^.AGLContext:=nil;
|
Info^.AGLContext := nil;
|
||||||
FreeAGLControlInfo(Ref);
|
FreeAGLControlInfo(Ref);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user