Allegro.cc - Online Community
Post Reply

Allegro.cc Forums » Allegro Development » Use an external window handle

rss feed Print
Use an external window handle
tinyBigGAMES
Member #17,458
February 2020
avatar

Is it possible to tell allegro to use an existing window handle? I want to make some tools and have the rendering occur within the panel of this tool.

Jarrod Davis
Owner/Lead Developer
tinyBigGAMES LLC

Arthur Kalliokoski
Second in Command
February 2005
avatar

https://www.allegro.cc/manual/5/al_get_win_window_handle

Teh mighty Google knows all, tells all. Took me 5 seconds.

They all watch too much MSNBC... they get ideas.

tinyBigGAMES
Member #17,458
February 2020
avatar

I don't mean get the created window handle, I mean, when I create a window, I need it to use and existing window handle. For example, you have a tool and you need rendering to occur within the bounds of your panel. In al_create_window for example, you pass the handle of that panel and rendering occurs in with it.

al_create_window_from_handle(HWND handle)

something like this, where instead of creating a new window, it will using and existing window.

Update:
I found this
https://www.allegro.cc/manual/4/platform-specifics/windows-specifics/windows-integration-routines/win_set_window

Is there such a thing for allegro5?

Jarrod Davis
Owner/Lead Developer
tinyBigGAMES LLC

Arthur Kalliokoski
Second in Command
February 2005
avatar

Since the platform specific functions section only has al_get_win_window_handle() and a couple of iphone functions, I suspect not. You can't think of a way to do it the other way round, e.g. create an allegro window and call the window specific stuff to get the final result?

I typed the above before I saw your edit, I don't know and haven't programmed in years.

They all watch too much MSNBC... they get ideas.

tinyBigGAMES
Member #17,458
February 2020
avatar

Well, I would design the tool visually. You see the 3 panels, I would need rendering to occur in the panel1. Each panel has an HWND handle, I would just need to pass this to allegro and rather than creating a whole window, it would use and existing one.
https://tinybiggames.com/temp/tool_design.jpg

Jarrod Davis
Owner/Lead Developer
tinyBigGAMES LLC

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Allegro cannot do this currently.

That said, you have a few options.

1. Draw into your external HWND by locking an offscreen allegro window and blitting. This will be slow.

2. Perhaps you could create an allegro window over the panel and make the panel's HWND it's parent. It could be frameless and would draw over the top seamlessly.

3. Hack allegro to get it to do what you want.

Allegro just isn't designed to render to an external HWND normally, because it takes over the window and manages it itself, which you probably don't want.

tinyBigGAMES
Member #17,458
February 2020
avatar

Ok, understand. Thanks for reply.

Jarrod Davis
Owner/Lead Developer
tinyBigGAMES LLC

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Arthur Kalliokoski
Second in Command
February 2005
avatar

Edgar is the source of all good programming bits here.

They all watch too much MSNBC... they get ideas.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

RmBeer2
Member #16,660
April 2017
avatar

You don't need a handle of window where you have a display.
Each new display is already a each new window.

EDIT:
Also, if by something reason you want work with handle for work with opengl or any other hack thing, it work only with windows.

🌈🌈🌈 🌟 BlackRook WebSite 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021!

tinyBigGAMES
Member #17,458
February 2020
avatar

See this link:
https://www.allegro.cc/manual/4/platform-specifics/windows-specifics/windows-integration-routines/win_set_window

This is what I was asking about. Was there something like this, because I need allegro5 to render to an EXISTING window handle, not one that it manages internally. But it's apparent that allegro5 does not have this feature currently. I'm a coder so hacking one would not be an issue for me to try, but I don't know enough about how A5 works internally to get that working right now.

Option #2, as pointed out seemed like it would be the next best option to try, however, the panel that is dropped on the form already has a fully initialized HWND handle and its managed internally. I don't see an easy way to make it use a different one as it managed by the VCL framework that controls it. Sigh.

Jarrod Davis
Owner/Lead Developer
tinyBigGAMES LLC

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

No, you misunderstand option #2. Make the panel's HWND the parent of a frameless allegro window that you integrate seamlessly over the panel.

tinyBigGAMES
Member #17,458
February 2020
avatar

I understand you, the problem is that when you drop a panel component on the form, internally it will create a handle and the Handle property only has a getter. It's managed internally by the VCL framework. In other words, by the time I have access to the panel properties, the win32 HWND handle for it has already been created and you can only reference it. Like Allegro5, it creates its own HWND internally. I may be able to make a custom panel where I can allow setting the handle. That's something else I can look into.

Jarrod Davis
Owner/Lead Developer
tinyBigGAMES LLC

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

No, you still misunderstand.

Create allegro window. Get its HWND. Get the external HWND of the panel using your getter. Call SetParent(eHWND) on the allegro window.

UPDATE
Bump for news of status.

Post Reply
Go to: