Mesh disappears when switching to 2. display

Problems building or running the engine, queries about how to use features etc.
Post Reply
Flaxxen
Gnoblar
Posts: 4
Joined: Sat Feb 14, 2015 9:28 pm

Mesh disappears when switching to 2. display

Post by Flaxxen »

Hey guys,

first of all I'm really new to 3D Development and I'm playing a bit with it now to get a feeling and
later create larger Projects.

What I did:
I have created my mesh by myself with HardwareVertex and HardwareIndexbuffer because I want to create a
"Tile" based map.

I began like the example in the Ogrewiki http://www.ogre3d.org/tikiwiki/Generating+A+Mesh
and made my Tile.

Problem:
If I drag the application onto my other display my mesh is gone. It simply disappears.

What I found out:
- The mesh itself is in the memory
- Tried to catch the D3D9 device destroy, grab the mesh and recreate the vertex and indexbuffers ( crash )
- Tried to destroy the SubMesh and rebuild it ( crash on destroySubMesh(0) )
- Tried to grab the submesh and recreate the vertex and indexbuffers ( crash because the Submesh->indexData is NULL ???? )
- Same happend with the code at http://www.ogre3d.org/tikiwiki/Generating+A+Mesh
- Tried a Mesh from a File like ogrehead.mesh aaaaand works all fine

I'm using:
- Windows 8.1
- VS2012
- Ogre 1.9
- Qt 5.4


What am I doing wrong?
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Mesh disappears when switching to 2. display

Post by frostbyte »

try using manualObjects http://www.ogre3d.org/tikiwiki/ManualObject
with ManualObject::convertToMesh(...) http://www.ogre3d.org/docs/api/1.9/clas ... 7f02b07efe
it should be safe from deviceLost...according to sinbads answer from here...http://ogre3d.org/forums/viewtopic.php? ... 60#p231392
Tried to catch the D3D9 device destroy, grab the mesh and recreate the vertex and indexbuffers ( crash )
if you dont want to use convertToMesh and want to recreate the buffers you can try to use HBL_DISCARD flag on you hardwareBuffer creation
not sure if thats the problem...you'll have to check...

tell us if its solved...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
Flaxxen
Gnoblar
Posts: 4
Joined: Sat Feb 14, 2015 9:28 pm

Re: Mesh disappears when switching to 2. display

Post by Flaxxen »

Tried it with a ManualObject and convert to Mesh, same problem here.

Here is a very simplified example:

Code: Select all

  Ogre::ManualObject *pManual = this->pSceneMgr->createManualObject();
  Ogre::Vector2       Position (0.0f, 0.0f );

  pManual->begin("Test/ColourTest", Ogre::RenderOperation::OT_TRIANGLE_STRIP, "RootResource");

  pManual->position    (Position.x           , 0.0f, Position.y + 16 );
  pManual->textureCoord(0.0f                 , 1.0f                  );
  pManual->position    (Position.x + 16, 0.0f, Position.y + 16       );
  pManual->textureCoord(1.0f                 , 1.0f                  );
  pManual->position    (Position.x + 16, 0.0f, Position.y            );
  pManual->textureCoord(1.0f                 , 0.0f                  );
  pManual->position    (Position.x           , 0.0f, Position.y      );
  pManual->textureCoord(0.0f                 , 0.0f                  );

  pManual->end();
  pManual->convertToMesh("TileMesh", "RootResource" );

  Ogre::Entity *pEntity = this->pSceneMgr->createEntity("TileMesh");
  this->pSceneMgr->getRootSceneNode()->setPosition(0.0f, 0.0f, 0.0f);
  this->pSceneMgr->getRootSceneNode()->attachObject(pEntity);
Its okay with ALT+TAB, CTRL+ALT+DEL etc. but switching the display kills it.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Mesh disappears when switching to 2. display

Post by frostbyte »

maybe try different render system...
your best chance if no one has a solution is to try it with ogre 1.10( build it from default branch ) maybe its fixed...
else you can dive to the ogre .mesh creation code and find out what's different about it...benefits of open source...
you can also submit a bug report with JIRA http://www.ogre3d.org/developers/submit-patch
or if you already fixed the bug submit a patch...

edit: if you are using the precompiled sdk then try building it from source....so many bugs fixed since...
if you don't want to build it yourself you can use transporters snapshots http://www.ogre3d.org/forums/viewtopic.php?t=69274
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
Flaxxen
Gnoblar
Posts: 4
Joined: Sat Feb 14, 2015 9:28 pm

Re: Mesh disappears when switching to 2. display

Post by Flaxxen »

Thanks for the reply,

I'm trying to build the Ogre version of 07.02.2015 and will report back later.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: Mesh disappears when switching to 2. display

Post by stealth977 »

I am not sure but the problem is probably due to Manual Loading of object.

It is possible that when switching monitors, the object's vertex/index buffer is getting invalid, in this case a normal mesh would reload, but a manual object needs to have a manual resource load listener to re-create its buffer... You can see a warning in LOG when using a manually created mesh, it says that there is no loader defined so the object will be lost when something happens to rendering device...
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
Flaxxen
Gnoblar
Posts: 4
Joined: Sat Feb 14, 2015 9:28 pm

Re: Mesh disappears when switching to 2. display

Post by Flaxxen »

Trier toDebug yesterday, thanks for the tip of the listener, I will try it if I am at home at the weekend.

I also found out that the Open GL Rendering Subsystem was able to reload the manual object. DirectX seems to have some trouble, but I've already read about that DirectX lost device is a pain.
Post Reply