Multiple monitors support patch – by Nir Hasson

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Multiple monitors support patch – by Nir Hasson

Post by Assaf Raman »

Multiple render monitors support patch – by Nir Hasson

I just committed Nir's patch to the trunk.
If there are any new problems that you see after updating the trunk code – post here.

Patch notes:
OGRE interface changes:
* Root::getDisplayMonitorCount() method added.
* "monitorIndex" parameter added to misc parameters of render window.

Feature implemented:
* D3D9 Render system supports multiple device creation.

* Multiple full screen render windows creation is now allowed.

* D3D9 multi-head feature on multi-head cards is used where possible.

* Resource creation policy support added( now there are two options):
1. Create on active device - the resource is created on active device only. If the resource does not exist on a device that needs it - it will be created on the fly. This policy is memory friendly but might cause performance issues when working intensively with a background loader thread.
2. Create on all devices - when a resource is being loaded it create itself on every existing devices. That policy consumes memory but is good when working with background loader thread.

* On the fly device switch is done - when dragging a windowed render window to a different display monitor, the window will automatically link to the optimal device.
Remark: You will have performance if a window extends to more then one monitor.

* Added to OpenGL render system a minimal support for multiple display monitors. Multi-monitor support in OpenGL is limited compared to D3D and required specific company extensions (ex: WGL_NV_gpu_affinity) – this patch cover all that it can before using such extensions.
If you want to see this patch in action – look for MULTIPLE_MONITOR_RENDER_MODE in the playpen.

More info about this commit can be found on the following threads:
Re: [Solved] multihead/multiscreen in mainstream 1.6 (DirectX)
D3D9 RS - force device recreate
Multihead patch 1.6

Image

Image



Image

Image



Image

Image


Image Nir! Image

This is one of the biggest patches that I saw in a while, great work Nir.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Multiple monitors support patch – by Nir Hasson

Post by Assaf Raman »

I just made a quick commit to some leftovers:
* Replaced the std::map and std::vector to the way that support the costume memory allocator.
* Updated the vc7 and vc9 projects.
Watch out for my OGRE related tweets here.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Multiple monitors support patch – by Nir Hasson

Post by jacmoe »

Awesome, Nir! :D

And Assaf, of course. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: Multiple monitors support patch – by Nir Hasson

Post by madmarx »

hurray for both Nir and Assaf!
:D

You did a great job at doing it "generalistic" with the different "resource strategies". Very good.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Multiple monitors support patch – by Nir Hasson

Post by Thieum »

Congratulations, Nir ! \o/
User avatar
enkuklios
Gnoblar
Posts: 23
Joined: Fri Nov 04, 2005 5:33 am

Re: Multiple monitors support patch – by Nir Hasson

Post by enkuklios »

Thats really awesome, nj both.

The screenshots above show the same scene rendered on multiple monitors, does this patch also allow a single scene to be spread across multiple?
MattStevens
Goblin
Posts: 239
Joined: Mon Apr 07, 2008 10:27 pm
x 4

Re: Multiple monitors support patch – by Nir Hasson

Post by MattStevens »

enkuklios, there is a couple of ways to span a scene across multiple monitors.

1- Span your monitors with Nvidia drivers. You don't need the patch, but it only works with NVidia drivers (and I heard it doesn't work on vista either)
2- Make 2 RenderWindow with 2 cameras side-by-side. If you have 90deg FOV horizontally, rotate both of them 45deg on opposite direction. The resulting images will looks like the scene got broken in half, in a kind of triangle if you see what I mean, but depending on what you're doing it might be fine.
3- Lastly, you do as number 2, but you set the projection matrix of the 2 frustums to make them parallele, as if you had a single frustum. It fixes the problem of #2 but you need more tweaking.

- Matt
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Re: Multiple monitors support patch – by Nir Hasson

Post by toglia »

I tried applying this patch to the release version of Ogre 1.6.1 with GNU patch 2.5.9 but I got a runtime error.
http://sourceforge.net/tracker2/?func=d ... tid=302997

patching file OgreD3D9GpuProgramManager.h
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
This application has requested the Runtime to terminate it in an unusual way.

would it work if I downloaded all these files from here and replaced them by hand?
http://ogre.svn.sourceforge.net/viewvc/ ... ision=8308
kiske
Greenskin
Posts: 106
Joined: Wed Jul 09, 2003 1:15 pm
Location: Trentino - ITALY
x 1

Re: Multiple monitors support patch – by Nir Hasson

Post by kiske »

toglia wrote:I tried applying this patch to the release version of Ogre 1.6.1 with GNU patch 2.5.9 but I got a runtime error.
http://sourceforge.net/tracker2/?func=d ... tid=302997

patching file OgreD3D9GpuProgramManager.h
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
This application has requested the Runtime to terminate it in an unusual way.

would it work if I downloaded all these files from here and replaced them by hand?
http://ogre.svn.sourceforge.net/viewvc/ ... ision=8308
I had the same problem using the patch.exe utility, but then I've tried to merge the patch with the utility in Tortoise SVN and all works as expected...
<Kiske>

Well can you blame us? For living our dreams...
- Twisted Sister -
glaciedge
Gnoblar
Posts: 3
Joined: Sun Mar 08, 2009 3:32 am

Re: Multiple monitors support patch – by Nir Hasson

Post by glaciedge »

Hi everyone~

I am trying to use this patch to combine multiple screens together. So far, I attached two cameras to two render windows, one for each, and adjusted the cameras to make it looks like a window that cross 2 screens.
It looks like this:
Image

I have some problems in applying CEGUI to my program. As you can see, the GUI appears on both render windows.
I want it to appear only on one of my render windows.

I have tried to change the render window in CEGUI::OgreCEGUIRender function, but it's still the same.

Does anyone know how can I show it only on one render window? :oops:
User avatar
eugen
OGRE Expert User
OGRE Expert User
Posts: 1422
Joined: Sat May 22, 2004 5:28 am
Location: Bucharest
x 8
Contact:

Re: Multiple monitors support patch – by Nir Hasson

Post by eugen »

You can use SetEnableOverlays(false) on one of the viewports to have it hidden
glaciedge
Gnoblar
Posts: 3
Joined: Sun Mar 08, 2009 3:32 am

Re: Multiple monitors support patch – by Nir Hasson

Post by glaciedge »

Thanks!! it's working now. :D
kiske
Greenskin
Posts: 106
Joined: Wed Jul 09, 2003 1:15 pm
Location: Trentino - ITALY
x 1

Re: Multiple monitors support patch – by Nir Hasson

Post by kiske »

I think should be a good idea to have in future versions an "overlay management", because many times there's the need to have some overlays in one renderwindow and other in the other renderwindow. I've implemented this through RenderTargetListeners, hiding or showing the overlays in the preRender event, but I need to mantain (and keep up to date) a list of overlays, and imho it's not a neat way to achive the result....
Just an idea would be adding a renderwindowlist in the overlay properties that someway tells the renderer in wich windows show this specific overlay and in wich not... Creating the overlay with this list void means all renderwindows shows the overlay....
<Kiske>

Well can you blame us? For living our dreams...
- Twisted Sister -
User avatar
Gucman
Orc
Posts: 467
Joined: Fri Dec 15, 2006 2:09 pm
Location: Poland, Lodz
x 1

Re: Multiple monitors support patch – by Nir Hasson

Post by Gucman »

Wow, that is very impressive. I was thinking about something like this (on one monitor you have the game and on the other the controlls to setup some parameters, some other view to see what is rendered, etc.). Finally I ended with two apps - one the game and second the editor both communicating through lan. It was quite handy but the time I spent writing all that communication stuff (and synhronising the views) was not worth the effect.
glaciedge
Gnoblar
Posts: 3
Joined: Sun Mar 08, 2009 3:32 am

Re: Multiple monitors support patch – by Nir Hasson

Post by glaciedge »

Hi kiske,

Can you tell me more detail about how did you use RenderTargetListeners to achieve this?
I have some problems again.... I want to show different GUI on each screen, but disable Overlays can not allow me to do this...
I have read this thread: http://www.ogre3d.org/forums/viewtopic.php?p=301408
and the other thread that you mentioned: http://www.ogre3d.org/forums/viewtopic. ... &view=next
but I am still not very sure how to do it, sorry.... I am a very beginner in Ogre3D :(


Thanks a lot!
kiske
Greenskin
Posts: 106
Joined: Wed Jul 09, 2003 1:15 pm
Location: Trentino - ITALY
x 1

Re: Multiple monitors support patch – by Nir Hasson

Post by kiske »

glaciedge wrote:Hi kiske,

Can you tell me more detail about how did you use RenderTargetListeners to achieve this?
I have some problems again.... I want to show different GUI on each screen, but disable Overlays can not allow me to do this...
I have read this thread: http://www.ogre3d.org/forums/viewtopic.php?p=301408
and the other thread that you mentioned: http://www.ogre3d.org/forums/viewtopic. ... &view=next
but I am still not very sure how to do it, sorry.... I am a very beginner in Ogre3D :(


Thanks a lot!
I've implemented like this:

Listeners.h

Code: Select all

#ifndef LISTENERS_H
#define LISTENERS_H

#include "stdafx.h"
#include <Ogre.h>
#include <OgreRenderTargetListener.h>
//RenderTargetListener

class RTL_Touch : public Ogre::RenderTargetListener
{
private:
	vector<string>	m_vszOverlaysToHide;

public:
	void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) ;
	void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); 

	void SetOverlaysToHide(vector<string> szOverlays);

	vector<string> GetOverlaysToHide();
	void AddOverlayToHide(Ogre::String szOverlayName);
	void RemoveOverlayToHide(Ogre::String szOverlayName);
};

class RTL_Proiettore : public Ogre::RenderTargetListener
{
private:
	vector<string>	m_vszOverlaysToHide;

public:
	void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) ;
	void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); 

	void SetOverlaysToHide(vector<string> szOverlays);

	vector<string> GetOverlaysToHide();
	void AddOverlayToHide(Ogre::String szOverlayName);
	void RemoveOverlayToHide(Ogre::String szOverlayName);
};
#endif //LISTENERS_H
Listeners.cpp

Code: Select all

#include "Listeners.h"


//////////////////////////////////////////////////////////////////////////
// RTL Proiettore

void RTL_Proiettore::SetOverlaysToHide(vector<string> szOverlays)
{
	m_vszOverlaysToHide = szOverlays;
}

vector<string> RTL_Proiettore::GetOverlaysToHide()
{
	return m_vszOverlaysToHide;
}
void RTL_Proiettore::AddOverlayToHide(Ogre::String szOverlayName)
{
	//////////////////////////////////////////////////////////////////////////
	// verifico se è già nella lista
	for (int i = 0; i < m_vszOverlaysToHide.size(); i++)
	{
		if (m_vszOverlaysToHide[i] == szOverlayName)
			return;
	}

	m_vszOverlaysToHide.push_back(szOverlayName);
}

void RTL_Proiettore::RemoveOverlayToHide(Ogre::String szOverlayName)
{
	//trovo l'elemento
	vector<string>::iterator iter;
	for (iter = m_vszOverlaysToHide.begin(); iter != m_vszOverlaysToHide.end(); iter++)
	{
		if (szOverlayName == *iter)
		{
			m_vszOverlaysToHide.erase(iter);
			return;
		}
	}
}


void RTL_Proiettore::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) 
{
	for (int i = 0; i < m_vszOverlaysToHide.size(); i++)
	{
		Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().getByName(m_vszOverlaysToHide[i]);

		if (pOverlay)
		{
			pOverlay->show();
		}
	}
}

void RTL_Proiettore::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
	for (int i = 0; i < m_vszOverlaysToHide.size(); i++)
	{
		Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().getByName(m_vszOverlaysToHide[i]);

		if (pOverlay)
		{
			pOverlay->hide();
		}
	}
}



//////////////////////////////////////////////////////////////////////////
// RTL Touch

void RTL_Touch::SetOverlaysToHide(vector<string> szOverlays)
{
	m_vszOverlaysToHide = szOverlays;
}

vector<string> RTL_Touch::GetOverlaysToHide()
{
	return m_vszOverlaysToHide;
}
void RTL_Touch::AddOverlayToHide(Ogre::String szOverlayName)
{
	//////////////////////////////////////////////////////////////////////////
	// verifico se è già nella lista
	for (int i = 0; i < m_vszOverlaysToHide.size(); i++)
	{
		if (m_vszOverlaysToHide[i] == szOverlayName)
			return;
	}

	m_vszOverlaysToHide.push_back(szOverlayName);
}

void RTL_Touch::RemoveOverlayToHide(Ogre::String szOverlayName)
{
	//trovo l'elemento
	vector<string>::iterator iter;
	for (iter = m_vszOverlaysToHide.begin(); iter != m_vszOverlaysToHide.end(); iter++)
	{
		if (szOverlayName == *iter)
		{
			m_vszOverlaysToHide.erase(iter);
			return;
		}
	}
}


void RTL_Touch::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) 
{
	for (int i = 0; i < m_vszOverlaysToHide.size(); i++)
	{
		Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().getByName(m_vszOverlaysToHide[i]);

		if (pOverlay)
		{
			pOverlay->show();
		}
	}
}

void RTL_Touch::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
	for (int i = 0; i < m_vszOverlaysToHide.size(); i++)
	{
		Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().getByName(m_vszOverlaysToHide[i]);

		if (pOverlay)
		{
			pOverlay->hide();
		}
	}
}
It is initialized like this:

Code: Select all

RenderTarget* RT_Proiettore = vp->getTarget();
	m_RTListenerProiettore = new RTL_Proiettore;

	vector<string> OverlaysToHide;
	OverlaysToHide.push_back("MouseCursor");
	m_RTListenerProiettore->SetOverlaysToHide(OverlaysToHide);

	RT_Proiettore->addListener(m_RTListenerProiettore);
I don't think this is the best way to do this, but it works... :)
<Kiske>

Well can you blame us? For living our dreams...
- Twisted Sister -
kiske
Greenskin
Posts: 106
Joined: Wed Jul 09, 2003 1:15 pm
Location: Trentino - ITALY
x 1

Re: Multiple monitors support patch – by Nir Hasson

Post by kiske »

I bring up to life again this topic...

Had anyone a better idea for showing/hiding the overlays than the one I've used with RenderTarget Listeners?
<Kiske>

Well can you blame us? For living our dreams...
- Twisted Sister -
ava
Halfling
Posts: 52
Joined: Tue Dec 29, 2009 3:55 pm

Re: Multiple monitors support patch – by Nir Hasson

Post by ava »

Is this the latest multi-monitor support or is there newer?

Seems this should be part of the main source, thought ogre was not just a game engine? :)

A lot of files to change. can anyone tell me quickly or give me a link on how to apply thois patch?
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Multiple monitors support patch – by Nir Hasson

Post by al2950 »

To be honest the easiest way is probably just to use the Ogre trunk. This patch is part of main Ogre core as of 1.7
kiske
Greenskin
Posts: 106
Joined: Wed Jul 09, 2003 1:15 pm
Location: Trentino - ITALY
x 1

Re: Multiple monitors support patch – by Nir Hasson

Post by kiske »

al2950 wrote:To be honest the easiest way is probably just to use the Ogre trunk. This patch is part of main Ogre core as of 1.7
I can canfirm that the trunk works like a charm with multimonitor support!
<Kiske>

Well can you blame us? For living our dreams...
- Twisted Sister -
Oman
Gnoblar
Posts: 18
Joined: Mon Oct 05, 2009 7:53 am

Re: Multiple monitors support patch – by Nir Hasson

Post by Oman »

MattStevens wrote:enkuklios, there is a couple of ways to span a scene across multiple monitors.

2- Make 2 RenderWindow with 2 cameras side-by-side. If you have 90deg FOV horizontally, rotate both of them 45deg on opposite direction. The resulting images will looks like the scene got broken in half, in a kind of triangle if you see what I mean, but depending on what you're doing it might be fine.
3- Lastly, you do as number 2, but you set the projection matrix of the 2 frustums to make them parallele, as if you had a single frustum. It fixes the problem of #2 but you need more tweaking.

- Matt


Does anyone have some code samples for this?

Thanks
User avatar
wizzler
Kobold
Posts: 34
Joined: Tue Nov 10, 2009 1:22 pm

Re: Multiple monitors support patch – by Nir Hasson

Post by wizzler »

Nice patch. Especially combined with two different scene viewers. Perhaps it would be possible to implement ATI's eyefinity directly in OGRE. ;)
Image Image
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Multiple monitors support patch – by Nir Hasson

Post by Assaf Raman »

wizzler wrote:Nice patch. Especially combined with two different scene viewers. Perhaps it would be possible to implement ATI's eyefinity directly in OGRE. ;)
As far as I understand - it is impossible to implement eyefinity in a different way then actually using eyefinity.
eyefinity enables you to treat multiple monitors as a single monitor - then you can only render once for multiple monitors.
The problem with eyefinity is the field of view for the "side monitors" - you will see the image starched without special compositors.
I didn't get to try eyefinity out yet - but if I will be able to solve the "side monitors" issue - I think it will be a real performance boost.
Watch out for my OGRE related tweets here.
juharkonen
Gnoblar
Posts: 13
Joined: Wed Oct 22, 2008 8:32 am

Re: Multiple monitors support patch – by Nir Hasson

Post by juharkonen »

Thanks Assaf and Nir for this update. Our project uses the multi-head feature to render on two fullscreen windows on two different displays simultaneously but there seems to be some issues with device lost/restored handling with this setup. As a note the device lost/restored works perfectly if I configure the application to use only one fullscreen window.

Here's some debug info regarding the behavior with multi head (on a Win7 system) with 2 output windows:
  • after start-up both windows render correctly
    • click-selecting on the secondary window keeps focus on the fullscreen windows
  • after first device lost+restored event pair (by activating another window with alt-tab and re-activating primary render window):
    • primary window renders correctly
    • secondary window is no longer rendered: calling swapbuffers on it switches between a black frame and the last frame rendered on the window
    • selecting the secondary window causes the fullscreen windows to lose focus
  • after second device lost+restored event pair:
    • updating the render window throws:

      Code: Select all

      OGRE EXCEPTION(3:RenderingAPIException): Cannot reset device! in D3D9RenderWindow::reset at .\src\OgreD3D9Device.cpp (line 421)
    • destroying a window or deleting ogre root object throw AccessViolationException
Has anyone observed this behavior before? Is there something that can be done about it? I've looked around device handling in the source but don't feel like I'm the right person to sort this out on the source level.
zerosith
Gnoblar
Posts: 5
Joined: Thu Mar 17, 2011 6:17 am

Re: Multiple monitors support patch – by Nir Hasson

Post by zerosith »

Hi, thanks for this patch, I was wondering if i could use this to render a scene in multiple monitors each one attached to a pc. and updating the whole scene rendering via network.

An example would be a ring of monitors and the user in the centre of them, if the user walks through a terrain, all the monitors should reflect the movement according to the whole scene. (each monitor attached to a CPU)


thanks
Post Reply