Kwang1imsa
11-02-2011 16:12:49
Hi community,
I'm relatively new to MOGRE, and I've been running into a few problems.
Whenever I run into an exception, an open file dialog pops up and asks be to browse for something like "vector.cpp" or "ogrewin.cpp" or some C++ source file. Afterwards, it throws an exception.
I'm not exactly sure what to do when this happens. Is this a problem with my code or distribution? I try to incorporate the try/catch statements to handle it, but it doesn't work since it's not an OgreException.
Also, it whines about an error with corrupted memory after I close my application. I remembered to dispose of all my objects, but unfortunately it still has that error.
I'd appreciate some advice.
Thanks.
Beauty
11-02-2011 23:38:11
Hello Kwang1imsa,
welcome to our Mogre world.
I'm sad to hear that you have problems.
Is there a line in the file
ogre.log, which starts with WARNING or EXCEPTION ?
Did you install Mogre by the MogreSDK?
Did you try the
Basic Mogre Tutorials?
If not, I suggest to read and try them.
If you tried the tutorials - are they running fine or does they cause problems, too?
Kwang1imsa
16-02-2011 15:10:07
So far I am loving MOGRE.
I'm embedding MOGRE into a windows forms panel. However, when I close the window, I get:
AccessViolationException was Unhandled:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I've managed to fix the other problems by referencing all of the tutorials.
I just can't seem to get this one down. I've disposed/destroyed everything, and I thought that should take care of it.
Any help much appreciated.
Thanks.
Beauty
17-02-2011 00:08:50
I also had such a problem long time ago. Unfortunately I can't remember details.
Maybe it was in relation with types with are ending with ...Ptr (a pointer variable?).
If I remember right, variables of such types have to be disposed before the application and/or Ogre shuts down.
In my Form I added a callback function for disposing. It will be called when the user exits the application e.g. by clicking the [X] symbol in the top right corner of the window.
I looked to my code. Beside other disposing calls, I added this related to Mogre.
(Maybe it was the solution for my problems?)
// defineed in the Form
this.Disposed += new EventHandler(OgreForm_Disposed);
// the callback function
void OgreForm_Disposed(Object sender, EventArgs e)
{
if (this.root != null)
this.root.Dispose();
this.root = null;
}
Additionally it could be important of the order of disposing.
For example you can't dispose a mesh, when the root was destroyed before.
Maybe it's also good to check a variable for null value before you call Dispose().
Just some ideas that could help.
Could you figure out the place where the Exception was thrown?
(For this debugging case you should not catch exceptions in a try/catch block.)
Did you check the logfile for warnings or errors?
AliAkdurak
17-02-2011 12:16:48
Well I suffered a lot because of I did not now few basics
![Very Happy :D]({SMILIES_PATH}/icon_biggrin.gif)
. So I will try to pass what I have seen.
First of all which render system are you using. It really changes a lot when you are going to embed your render window in to a panel.
D3D works fundamentally multi threaded which means you can go ahead and create Render windows which did not created by the thread that created the first render window aka primary window because many engines an ogre create it's underlying render system at the first call for render window. But D3D 9 has a very bad management of the Device Context(System to hold the current state of the Graphic drive) which creates problems when you decide to create multi render window applications on the same display or move them around. You will meet the D3D reset device error at that point.
OpenGL has a restriction of forcing you to call everything render related from a single thread. If you are planning to build a large application using many render windows and monitors you should plan ahead and correctly plan your render system controller to be only one thread. We had done this by making delegated queued calls to a thread dedicated to rendering. Details can be provided if anyone needs.
OpenGL is a little bit more tricky because of this thread requirement you should check what you dispose or which events you are listening and when they get invoked or when they just work.
For using rendering in winforms we made a class called MogrePanel which inherits from System.Windows.Blabla.Panel and dock it as you would dock any panel to any window. It is really convenient to use in such way.
Having said these I still have many problems with OpenGL about changing thread context which I will post right after I post this message
![Smile :)]({SMILIES_PATH}/icon_smile.gif)
. So If you can give me a little bit more clues may be I can pin your problem.
Hmm another simple advice never null anything from mogre before you call the appropriate destroyer from the related place. Like to null a scenemanager use Root.DestroySceneManager and for renderwindows use Root.DestroyRenderWindow for nodes use SceneManager.DestroyNode etc dont forget to deattach stuff before you destroy. That is all I experienced until now
Kwang1imsa
20-02-2011 04:54:56
Hey,
Thanks for all these comments. I'm so glad to see that MOGRE has such a dedicated and helpful community.
I've checked the logfile and no errors. I'm using the OpenGL rendering subsystem.
However, I have found something very interesting...
When I click "View Details", I get:
---------------------------
View Detail...
---------------------------
Object reference not set to an instance of an object.
---------------------------
OK
---------------------------
I don't use any of my objects after I have destroyed them. I think this is pretty odd.
Thanks again for the replies.
Kwang1imsa
20-02-2011 04:59:28
More:
Source File information:
Locating source for 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'. Checksum: MD5 {3e 1c e6 2 e9 56 55 fa 57 5c c5 12 e5 25 ea 22}
The file 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h' does not exist.
Looking in script documents for 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'...
Looking in the projects for 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vc7\atlmfc'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vc7\crt'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: d:\devel\gamedevel\mogre\main\include\auto\mogreroot.h.
The debugger could not locate the source file 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'.
Call Stack location:
Mogre.dll!Mogre.Root.!Root() Line 72 + 0x2f bytes
This doesn't happen unless I actually show the form that I'm embedding MOGRE into.
AliAkdurak
20-02-2011 06:13:16
Source File information:
Locating source for 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'. Checksum: MD5 {3e 1c e6 2 e9 56 55 fa 57 5c c5 12 e5 25 ea 22}
The file 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h' does not exist.
Looking in script documents for 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'...
Looking in the projects for 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vc7\atlmfc'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vc7\crt'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: d:\devel\gamedevel\mogre\main\include\auto\mogreroot.h.
The debugger could not locate the source file 'd:\devel\gamedevel\mogre\main\include\auto\mogreroot.h'.
This message you recieved is a byproduct of the exception and does not give information about your problem. It says that after the exception your debuger tried to find the sources of the dll you used and failed.
There is a specific starting sequence for the mogre to run. Like having your render window created after the root initialise but before resource creation best way to look for it is to get mogrebasicframeworks source where it is layout so that you can see how to start a basic application. Also OpenGL can throw exceptions if it tries to render to a window which the same thread does not own. Can you post a ogre log and try to work with D3D just to see if it fails too?
AliAkdurak
20-02-2011 06:22:02
There is very good information provided in this post:
viewtopic.php?f=8&t=5300 Check the last and the second post specifically I hope this helps
Beauty
20-02-2011 12:43:44
Oh, I'm glad to see that you poin to one of my posts.
I thought, I couldn't help, but now I still did.
Additionally I got the idea to put the post with the starting order to the wiki. (There is a tutorial for usage in Windows Forms.)
CodeKrash
20-02-2011 20:08:40
if you want a debuggable environment you should save your ogre/mogre build environment so that you can direct visual studio at it.
"debug" binaries, and pdb files are important too
also check "debug native code" in the C# project properties/debug tab, not sure what the equiv is for non c#
Kwang1imsa
24-02-2011 17:02:49
Hey guys, thanks for the replies again.
So it works without fail in Direct3D9, but I would like to use OpenGL if I could.
For some reason the camera seems a little warped when I changed from OpenGL to D3D9.
So I guess the problem is OpenGL trying to draw to a nonexistent window?
Beauty
24-02-2011 22:34:20
Sorry, I have no experience with OpenGL and no idea about.
If the problem is not Mogre specific (means: also relevant to C++ Ogre), then you could ask in the Ogre main forum. There are much more users and experts who can answer.