Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Custom Window With SFML  (Read 3093 times)

0 Members and 1 Guest are viewing this topic.

Pandemodium

  • Newbie
  • *
  • Posts: 2
    • View Profile
Custom Window With SFML
« on: October 13, 2015, 10:09:17 am »
Hi all,

I'm thinking of creating an in-game app that is capable of attaching itself to a game window, drawing an external overlay over the top, and drawing chat from a twitch stream, so that I may use it while streaming video's.

However my attempts at using DirectX have proven near fatal to my mental health ( It's really hard to use - at least for me ), is it possible to do something similar in SFML?

Is it possible for me to create a custom form, then attach SFML to it?

Kind Regards,
Pandemodium

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Custom Window With SFML
« Reply #1 on: October 13, 2015, 10:16:44 am »
This is a non-trivial advanced topic. As easy as "attaching itself to a game window" sounds, it is quite complex.
In order to do that you need to work with whatever API the game is using, so you'll have to write both a DirectX and OpenGL solution. Then you need to hook into the game itself which is often done through DLL injection, etc.
Try googling "opengl/directx hook" and "DLL injection" to learn more about these topics.

Personally I suggest you just pick an existing solution - there are quite a few out there.

So, no SFML won't help you for your task in any way.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Custom Window With SFML
« Reply #2 on: October 13, 2015, 11:07:57 am »
Best bet for you - and probably easiest as well - would be just drawing your overlay/chat to a normal SFML window and merging everything in your streaming app (like OpenBroadcaster). This is far easier and saves you the trouble of having to hook up multiple libraries (you'd have to provide interfaces for DirectX 9, DirectX 11, and OpenGL at least).

Pandemodium

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Custom Window With SFML
« Reply #3 on: October 13, 2015, 03:24:36 pm »
This is a non-trivial advanced topic. As easy as "attaching itself to a game window" sounds, it is quite complex.
In order to do that you need to work with whatever API the game is using, so you'll have to write both a DirectX and OpenGL solution. Then you need to hook into the game itself which is often done through DLL injection, etc.
Try googling "opengl/directx hook" and "DLL injection" to learn more about these topics.

Personally I suggest you just pick an existing solution - there are quite a few out there.

So, no SFML won't help you for your task in any way.

My MO so far has been to inject myself in as a DLL, then create an Overlay Window (made transparent using DwmExtendFrameIntoClientArea), then to complete this I draw on the overlay. However my application of directX is not drawing anything. I think I have to go back to basics in DirectX, then re-apply this to my overlay.

Existing solutions don't have the features I'd like, which is why I opted to make my own. Don't get me wrong I didn't expect it to be easy, I'll just go back to my DirectX tutorials and start over, until I solve this.

Best bet for you - and probably easiest as well - would be just drawing your overlay/chat to a normal SFML window and merging everything in your streaming app (like OpenBroadcaster). This is far easier and saves you the trouble of having to hook up multiple libraries (you'd have to provide interfaces for DirectX 9, DirectX 11, and OpenGL at least).

I had thought of this initially, but I don't want the people in the stream to see the messages. They already see them in the side panel on Twitch. I want to be able to see them myself over my game without disturbing their view. So sadly this won't help me.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Custom Window With SFML
« Reply #4 on: October 13, 2015, 03:34:13 pm »
I had thought of this initially, but I don't want the people in the stream to see the messages. They already see them in the side panel on Twitch. I want to be able to see them myself over my game without disturbing their view. So sadly this won't help me.

Ah! That's even easier. Just pick a different recording method. Don't use screen/desktop recording. Instead try window recording or game recording (might be named differently based on the program used). This should allow you to capture the game window without also capturing anything overlapping it (not even the mouse cursor).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Custom Window With SFML
« Reply #5 on: October 13, 2015, 03:36:01 pm »
I had thought of this initially, but I don't want the people in the stream to see the messages. They already see them in the side panel on Twitch. I want to be able to see them myself over my game without disturbing their view. So sadly this won't help me.
Get a second monitor then. A lot easier and a lot more useful. If it costs too much think about the time you've already invested in the project for which you could've worked instead and made money. :P

Ah! That's even easier. Just pick a different recording method. Don't use screen/desktop recording. Instead try window recording or game recording (might be named differently based on the program used). This should allow you to capture the game window without also capturing anything overlapping it (not even the mouse cursor).
Except he has no overlay of the Twitch chat yet! That's exactly what he's trying to implement.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Custom Window With SFML
« Reply #6 on: October 16, 2015, 03:20:41 pm »
The app that is overlay ui is just another programm working in parallel - examp steam overlay ui it actually a basic programm (steamOverlayUi.exe) that i launched along with steam game and handled to it - so it doesn't affect on game at all because it just a parralel programm.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Custom Window With SFML
« Reply #7 on: October 16, 2015, 04:21:17 pm »
Yeah but while the overlay is active you also can't do anything to the underlying game. Plus, I thought you had to explicitly support steam overlay in your game.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Custom Window With SFML
« Reply #8 on: October 16, 2015, 04:45:41 pm »
It is actually no support at all - any game can support steam overlay. Actually when launch a game from steam bootstrapper the steam system launches a game and then handles a window on it - nothing special and when you press shift+Tab this window of overlay pops up - it just some multithreading trick. As proof for overlay support in game is five nights at freddys - it a game on click team fusion engine while all valve games are on my favourite source engine - here is a proof. So,want have steam overlay in your game? Just ask steam for it.   ;D