Redirecting video output to a different app

killall -9

Moderator: Developers

Post Reply
User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

Redirecting video output to a different app

#1

Post by doomista » Sat Feb 25, 2017 7:01 pm

Okay, I might get stomped for this question, but is it possible to redirect the video output of zandronum to a different program without modifying zandro's source? Something similar to Xming where you can ssh to a remote machine, run graphical program and get it's window opened on your local machine.

Or do I have to actually dig into the source code and find the way to pass pointer to OpenGL render context to the other program?

I am well aware that many people here are allergic to word spliscreen and I am well aware of reasons why it isn't implemented in ZDoom/GZDoom/Zandronum, etc. I just have this idea in my head for quite some time and I want to know whether this can be done (and try to code it by myself in case it is possible). I know this isn't just about rendering, there is audio to be dealth with and controllers as well (a bit shame core is written in SDL, SFML would deal with all of this for me), but let's take it more as a programming exercise.

Thanks for responses

User avatar
ZZYZX
Posts a lot
Posts: 742
Joined: Thu Jun 07, 2012 5:56 pm
Location: Ukraine
Clan: A3
Clan Tag: [A3]

Re: Redirecting video output to a different app

#2

Post by ZZYZX » Sat Feb 25, 2017 7:20 pm

Taking Zandronum's window and repositioning it can work. In a way similar to what window managers on Linux do, except on Windows.
That's the easy way that will work with all rendering backends (DirectDraw, Direct3D, OpenGL).

The hard ways are:
1. trying to implement it in Zandronum itself.
2. replacing opengl32.dll and whatever DDraw/D3D libraries are used (d3d9.dll?) in a way similar to DxWnd and QEffectsGL.
3. ??? (pretty sure there are more hard ways I didn't think of right now)

User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

Re: Redirecting video output to a different app

#3

Post by doomista » Sat Feb 25, 2017 9:09 pm

I am not sure whether replacing .dll libraries would help my cause. I just need to somehow retrieve the established render context and embed it into another app, where I can make multiple viewports and have it fullscreen without window borders.

My idea so far is to print value of Window memory pointer to a text file, then load that file into my app, and access that pointer (but if I recall OS lectures from college correctly it won't work since that memory would be protected). Plus that would require modifying source code (and zdoom source cannot be compiled because of some missing headers).

User avatar
ZZYZX
Posts a lot
Posts: 742
Joined: Thu Jun 07, 2012 5:56 pm
Location: Ukraine
Clan: A3
Clan Tag: [A3]

Re: Redirecting video output to a different app

#4

Post by ZZYZX » Sun Feb 26, 2017 7:28 pm

Some unstructured points here.

1. With replacing .dll libraries you could intercept wgl calls (the ones that are used to create, set and delete contexts).
2. However, getting the CONTEXT won't help you much really IMO. Doing anything useful (aside from postprocessing) with the GL context requires you to be aware of target game's internals, that is, reimplementing parts of Zandronum manually in your external app.
3. Whereas querying other windows is not subject to memory protection, i.e. you can enumerate open windows, find Zandronum one and try to move/resize it around, or even embed it in your own "splitscreen" window. USE THIS APPROACH. (no, seriously).
The hardest thing you will have with #3 is that it's not possible to set arbitrary resolution (like 960x1080), and as such, you will have to implement hacky methods to actually make Zandronum use a resolution not supported by the video card.

User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

Re: Redirecting video output to a different app

#5

Post by doomista » Mon Feb 27, 2017 7:22 am

ZZYZX wrote: 3. Whereas querying other windows is not subject to memory protection, i.e. you can enumerate open windows, find Zandronum one and try to move/resize it around, or even embed it in your own "splitscreen" window. USE THIS APPROACH. (no, seriously).
The hardest thing you will have with #3 is that it's not possible to set arbitrary resolution (like 960x1080), and as such, you will have to implement hacky methods to actually make Zandronum use a resolution not supported by the video card.
Yup, that was basically what I was looking for, I didn't get it for the first time. The resolution will be a problem though, I was hoping for dealing with it via config files but that's not working. But for a start, making it work in at least the same crappy fashion Resident Evil 6 does will suffice. Thanks for explaining :)

Post Reply