Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Can I get a Carbon WindowPtr for a FireMonkey Form? Should I?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Feb 19, 2016 1:57 PM Last Post By: Sean Farley
Sean Farley

Posts: 9
Registered: 8/10/09
Can I get a Carbon WindowPtr for a FireMonkey Form? Should I?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2016 12:35 PM
I'm using RAD Studio 10 Seattle.

I'm still trying to get OpenGL working on my Mac. I think I've gotten pretty far using AGL, but I'm still missing one piece, which is a Carbon style WindowPtr. Is there a way to get a WindowPtr out of a FireMonkey Form, or should I abandon Carbon and switch to Cocoa?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Can I get a Carbon WindowPtr for a FireMonkey Form? Should I?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2016 1:15 PM   in response to: Sean Farley in response to: Sean Farley
Sean wrote:

I'm still missing one piece, which is a Carbon style WindowPtr.

Why do you need it?

Is there a way to get a WindowPtr out of a FireMonkey Form

Yes, but not directly.

FireMonkey uses Cocoa internally. You can retrieve a Form's native Cocoa
window by passing the Form's Handle property to the FMX.Platform.Mac.WindowHandleToPlatform()
function, which returns a TMacWindowHandle that provides access to the Form's
NSWindow object (and also its NSView, NSTrackingArea, and NSOpenGLView objects).
NSWindow has a windowRef property.

--
Remy Lebeau (TeamB)
Sean Farley

Posts: 9
Registered: 8/10/09
Re: Can I get a Carbon WindowPtr for a FireMonkey Form? Should I?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2016 1:57 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Sean wrote:

I'm still missing one piece, which is a Carbon style WindowPtr.

Why do you need it?

Is there a way to get a WindowPtr out of a FireMonkey Form

Yes, but not directly.

FireMonkey uses Cocoa internally. You can retrieve a Form's native Cocoa
window by passing the Form's Handle property to the FMX.Platform.Mac.WindowHandleToPlatform()
function, which returns a TMacWindowHandle that provides access to the Form's
NSWindow object (and also its NSView, NSTrackingArea, and NSOpenGLView objects).
NSWindow has a windowRef property.

--
Remy Lebeau (TeamB)

Thanks, Remy.

The sample code I'm working with has the following code block:

WindowPtr g_pWindow;
AGLPixelFormat g_pixelFormat;
AGLContext g_aglContext;

g_aglContext = aglCreateContext(g_pixelFormat, NULL);
aglSetDrawable(g_aglContext, (AGLDrawable)GetWindowPort(g_pWindow));
aglSetCurrentContext(g_aglContext);

I've created the pixel format and the context, but I haven't run the SetDrawable function. That's what I needed the WindowPtr for.

It sure looks like I should try to do this with cocoa instead, but I run into many errors when I try to include the cocoa headers.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02