ChrisTTian667
17-09-2007 19:54:05
Hello Guys,
i started programming with MOGRE. I did the Ogre Tutorials well, and now, i wants to use it without the MogreFramework.dll.
But this results in an AccessViolation, when trying to load the terrain.cfg
in this line
I am using VS 2005 Team Edition and it's saying: "Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist."
Its German, but means, that its trying to read/write to protected memory. Which is often a hint, that memory is defect. (Sorry, for my bad english!!)
Can someone give my at least a hint, what i am doing wrong?
cheers,
Christian
I post the complete Source here:
i started programming with MOGRE. I did the Ogre Tutorials well, and now, i wants to use it without the MogreFramework.dll.
But this results in an AccessViolation, when trying to load the terrain.cfg
in this line
mgr.SetWorldGeometry("C:\\ogresdk\\media\\terrain.cfg");
I am using VS 2005 Team Edition and it's saying: "Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist."
Its German, but means, that its trying to read/write to protected memory. Which is often a hint, that memory is defect. (Sorry, for my bad english!!)
Can someone give my at least a hint, what i am doing wrong?
cheers,
Christian
I post the complete Source here:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using Mogre;
namespace MogreVsODE
{
static class Program
{
[STAThread]
static void Main()
{
try
{
OgreMain myOgreMain = new OgreMain();
myOgreMain.Init();
myOgreMain.Go();
}
catch (System.Runtime.InteropServices.SEHException)
{
if (OgreException.IsThrown)
MessageBox.Show(OgreException.LastException.FullDescription, "An Ogre exception has occurred!");
else
throw;
}
}
}
public class OgreMain
{
private Root OgreRoot;
private RenderWindow OgreRenderWindow;
public OgreMain()
{
}
public void Init()
{
// Create root object
OgreRoot = new Root();
// Define Resources
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
// Setup RenderSystem
RenderSystem rs = OgreRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
OgreRoot.RenderSystem = rs;
rs.SetConfigOption("Full Screen", "no");
rs.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");
// Create Render Window
OgreRoot.Initialise(true, "Main Ogre Window");
// Init resources
TextureManager.Singleton.DefaultNumMipmaps = 5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
// Create a Simple Scene
SceneManager mgr = OgreRoot.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE);
Camera cam = mgr.CreateCamera("Camera");
cam.AutoAspectRatio = true;
if (File.Exists("C:\\ogresdk\\media\\terrain.cfg"))
{
mgr.SetWorldGeometry("C:\\ogresdk\\media\\terrain.cfg");
}
mgr.SetSkyDome(true, "Examples/CloudySky", 5, 8);
OgreRenderWindow = OgreRoot.AutoCreatedWindow;
OgreRenderWindow.AddViewport(cam);
Entity ent = mgr.CreateEntity("ninja", "ninja.mesh");
mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent);
cam.Position = new Vector3(0, 200, -400);
cam.LookAt(ent.BoundingBox.Center);
}
public void Go()
{
while (OgreRoot != null && OgreRoot.RenderOneFrame())
Application.DoEvents();
}
}