-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple GameWindow support for Windows/DirectX #1465
Conversation
…ow handle and exposes Present. Since it is a RenderTarget it can be set on the GraphicsDevice but Present needs to be called on it.
…re2D base constructor.
… Keyboard.SetKeys, rather than the GameWindow. This is to keep multiple windows from clobbering each other.
Can one of the admins verify this patch? |
@mgbot test |
Build results will soon be (or already are) available at: http://build.monogame.net/job/BuildPR/41/ |
@mgbot test |
Build results will soon be (or already are) available at: http://build.monogame.net/job/BuildPR/42/ |
@mgbot test |
Build results will soon be (or already are) available at: http://build.monogame.net/job/BuildPR/44/ |
Can one of the admins verify this patch? |
@mgbot test On 5 March 2013 22:59, MonoGame Build Bot notifications@github.com wrote:
|
@mgbot test |
Build results will soon be (or already are) available at: http://build.monogame.net/job/BuildPR/88/ |
Can someone else give this PR a test? Are there any concerns with adding this feature? |
I can give this a test later tonight/tomorrow, but how do I function it? create another GameWindow from within the main Game1.cs constructor? then to draw set RenderTarget to that window? |
Well first make sure it doesn't break any existing functionality in your game. If you want to then test the new features just create the second window in Game.Initialize:
Then in your Game.Draw do this:
It is pretty simple and you can create as many windows as you need. Also in theory you could pass a IntPtr handle to a non-GameWindow window as well... but we've not tried that. |
Well, I can make the other window show. However I cant render to it (its not displaying the correct color from GraphicsDevice.Clear()). This is my draw method:
The other window just has the default creamy-colored background. Also can I suggest that SwapChainRenderTarget gets a new constructor that is much more simple and automatically sets all the other settings (default settings)? new SwapChainRenderTarget(GraphicsDevice, gameWindow.Handle, 1000, 1000);? If people want the more customizable constructor they can use it aswell |
Are you sure you are building against MonoGame for Windows DX? It does not work under OpenGL yet.
Sure... no problem. I'll add that right now in fact. |
Note I came across the old Windows Mobile C# wrapper for DirectX and it too has a SwapChain class: Just noting the precedent for having this class in MonoGame. |
Rearraged the construtor parameters to match RenderTarget better. Resharper cleanups. Added some TODOs. Fixed some of the docs.
@xanather - Updated with the simpler constructor. |
It is a windows DirectX project. Code:
Edit: that didnt come out too well : / |
I edited your post to use code block formatting... take a look. Maybe try calling |
no difference, do you want me to upload the project? |
Hum. I have an idea... i'll test it over here first. I think there might be an error if you try to create the swap chain too early. Looking at our use we are creating the swap chain on first GameWindow.ClientSizeChanged event. |
Oh I see. I just tried after a 1 second timer, still doesn't work. |
I've been trying to test this, but I get E_FAIL (0x80004005) when trying to create the Direct3D11 device. No idea why. |
Hum.... i'll make sure I test a clean pull of this and verify some of the issues brought up here. |
@xanather - I went and tested your case... you just misinterpreted how to use the API. You had this:
... it should have been this...
So this it would be good if you can verify, but this PR does work. |
Are you guys good with this? Note that the high level plan is simplify swapchain/framebuffer management code in GraphicsDevice. I next want to add OpenGL support (not sure if GLES can support it). Also need to add resize support as that is missing right now. Then we can replace the existing swap chain creation/resizing code which makes up a ton of GraphicsDevice (and scattered about on OpenGL) with this class. |
@mgbot test |
Build results will soon be (or already are) available at: http://build.monogame.net/job/PullRequestTester/86/ |
ok by me On 5 April 2013 19:51, MonoGame Build Bot notifications@github.com wrote:
|
Oh cool, I will verify it soon |
yep with the change it works :) |
Multiple GameWindow support for Windows/DirectX
Adding support for multiple GameWindow(s) within a single game.
This is only implemented for WINDOWS && DIRECTX
Non-primary windows do not handle any input and for input events to reach the users game the primary window must be active. This can be improved at a later time when it is a needed feature.
The existing Game / Platform / GraphicsDevice code is largely unchanged and only deals directly with the standard, primary window which it also creates.
Example: